Nick DeVore
Nick DeVore

Reputation: 10166

Why Are There Multiple GET Requests Shown in Firebug?

So I'm at the stage in web programming where I'm past the "Look, Ma, I can put data in a grid and it shows up on the page." I'm now at the, wow, this site is not as snappy as I want it to be. So, I enabled the "Net" tab in Firebug, closed my eyes, crossed my fingers, and went spelunking.

The first thing I noticed is that all of my .aspx pages are being "GET"ed at least three times. Is this normal? If not, what is "normal"? What affects the "GET"ing of the .aspx pages? I'm assuming that includes the time it takes to hit the database and render all the controls on the page. Is that true?

Perhaps what would really benefit me is a place I can look to get some "best practices" for these kinds of speed related issues.

Things to consider:

EDIT Answers to questions below:

EDIT Screen shot added: FirebugScreenshot http://img187.imageshack.us/img187/5873/firebughelp.jpg

EDIT Added Additional Screenshot to include Request Headers

EDIT

Added links

Upvotes: 2

Views: 1277

Answers (7)

M.Hassan
M.Hassan

Reputation: 11032

This normally happen if you are in the Development Environment and "Enable browser link" in VS 2015/2013 . To avoid the Multiple GET Requests Shown in Firebug, uncheck "Enable browser link" from the tool bar. If you view the page source, you find script tag added to the page when you check "Enable Browser Link". This causes Get/Post Actions to the iis server. For more details: http://www.asp.net/visual-studio/overview/2013/using-browser-link

Upvotes: 1

tvanfosson
tvanfosson

Reputation: 532435

EDIT: Here is the source of your two extra page loads:

<script type="text/javascript"
        src='<%# ResolveUrl("~/Common/jQuery/jquery-1.3.2.min.js") %>'> 
</script>

<script type="text/javascript"
        src='<%# ResolveUrl("~/Common/jQuery/jquery-ui-1.7.1.custom.min.js") %>'> 
</script>

As you can see in the rendered version the src attribute is empty, causing it to load the page two extra times.

<script type="text/javascript" src=''></script>
<script type="text/javascript" src=''></script>

You can probably fix this by using the runat server tag and having it resolve the urls automatically.

<script type="text/javascript"
        src="~/Common/jQuery/jquery-1.3.2.min.js"
        runat="server"
        ID="jQuery"> </script>
<script type="text/javascript"
        src="~/Common/jQuery/jquery-ui-1.7.1.custom.min.js"
        runat="server"
        ID="jQueryUI"> </script>

(or change <%# %> to <%= %> -- since you need to have the version that outputs a string instead of the binding syntax).

Original answer removed since it was not related to the actual problem.

Upvotes: 5

Tsvetomir Tsonev
Tsvetomir Tsonev

Reputation: 106494

It's unlikely that those are AJAX requests, as the response length is the same on each request.

I'm also ruling out the bug with empty src attribute of img elements, as this only causes one reload of the page, not two.

There is a know bug with Telerik RadEditor that might cause such condition, but you don't mention it in the list of used controls. Here are more details about it:

http://www.telerik.com/community/forums/aspnet-ajax/editor/radeditor-forces-page-load-twice.aspx

You might also want to comment out the Telerik controls on the page to see if that helps.

Upvotes: 3

Ot&#225;vio D&#233;cio
Ot&#225;vio D&#233;cio

Reputation: 74250

If you have security enabled, that could be the challenge and response requests - first a 401 then a 200. What are the response codes that you are getting?

Upvotes: 0

David Hedlund
David Hedlund

Reputation: 129792

The browser should normally hit the server just once, and all the time it takes to query the database and whatnot should be confined within that request. If you're playing around with ajax controls, they're likely to query the server more times for new data. You can use firebug to inspect the requests and responses, and see what they contain.

A common cause for the aspx being requested several times is having IMG tags rendered without any SRC attribute. This will default to querying the same page for the image source. If this is the case for you, then you could check the request headers in firebug, to see if it expects an image.

You could also go to the console and type document.images to get a list of all the images. The ones that aren't visible on the page will be shown slightly faded. Inspect those for blank SRC's.

Upvotes: 1

blowdart
blowdart

Reputation: 56500

It could be lots of things - the important part of the request is what it's GETing.

Generally you're going to see more than one request for an ASPX page as it loads the javascript libraries to perform validation and postbacks. Controls can also have javascript embedded as resources, which in turn create other GET requests, usually for WebResource.axd and ScriptResource.axd.

Upvotes: 0

user434917
user434917

Reputation:

The browser makes a GET request for each resource included in the Page, including js files, images, css files...

Upvotes: 0

Related Questions