URL page load cycles

I am using Intelligencia UrlRewriter to apply URL rewriting.

I took page1.aspxand used the OnClickbutton event and did Response.Redirect- page2.aspx. Everything works fine if I test these two sample pages.

Then I applied some styles and javascript to page2.aspx. When I press the same button on page1.aspxand put a breakpoint in the function page2.aspx.cs page_load, what I observed is that the function page_loadloops several times and it loops through all the database calls several times.

Application IsPostbackdid not help. Then I deleted CSS and JS, then everything is fine. Answer why this function is page_loadrepeated several times.

+3
source share
3 answers

I also had this problem. Like others affected, this can be caused by relative paths within your page.

I rewrote:

domain.com/article/12345/title-here 

To become:

domain.com/article.aspx?ID=12345

The problem was that there were two images with relative paths:

  EG. images/fb.jpg
      images/tw.jpg

By writing the value to Request.RawUrl.ToString (), I could see that the browser was requesting the following images:

 domain.com/article/12345/images/fb.jpg

 domain.com/article/12345/images/tw.jpg

Although these files do not exist, the URL still complies with the redirect rule.

Thus, rewriting the url:

domain.com/article.aspx?ID=12345

This explains why my page loaded three times. Once for HTML and once for each image.

The src values ​​of the image were changed to an absolute path, and the problem was resolved.

+4
source

CSS JS. , css JS . CSS JS .

Edit ,

<rewrite url="^(/.+(\.gif|/.+\.png|\.jpg|\.ico|\.pdf|\.css|\.js|\.asmx|\.axd|\.flv|\.swf)(\?.+)?)$" to="$1" processing="stop" />
0

Page load points are also due to the implementation of ASP.Net. One way you can verify and reduce processing overhead is to check the httpContext object to see what the current requested object is. If the object is not what you expect - an image, a .js file, a stylesheet, etc. Exit page processing.

0
source

All Articles