Why does Fiddler break my site's redirects?

2020-04-30 18:05发布

问题:

Why does using Fiddler break my site sometimes on page transitions.

After a server side redirect -- in the http response (as found in Fiddler) I get this:

Object moved

Object moved to here.

The site is an ASP.NET 1.1 / VB.NET 1.1 [sic] site.

Why doesnt Fiddler just go there for me? i dont get it.

I'm fine with this issue when developing but I'm worried that other proxy servers might cause this issue for 'real customers'. Im not even clear exactly what is going on.

回答1:

That's actually what Response.Redirect does. It sends a 302 - Object moved response to the user-agent. The user-agent then automatically goes to the URL specified in the 302 response. If you need a real server-side redirect without round-tripping to the client, try Server.Transfer.



回答2:

If you merely constructed the request using the request builder, you're not going to see Fiddler automatically follow the returned redirect.

In contrast, if you are using IE or another browser, it will generally check the redirect header and follow it.

For IE specifically, I believe there's a timing corner case where the browser will fail to follow the redirect in obscure situations. You can often fix this by clicking Tools / Fiddler Options, and enabling both the "Server" and "Client" socket reuse settings.



回答3:

Thanks user15310, it works with Server.Transfer

Server.Transfer("newpage.aspx", true);

Firstly, transferring to another page using Server.Transfer conserves server resources. Instead of telling the browser to redirect, it simply changes the "focus" on the Web server and transfers the request. This means you don't get quite as many HTTP requests coming through, which therefore eases the pressure on your Web server and makes your applications run faster.

But watch out: because the "transfer" process can work on only those sites running on the server, you can't use Server.Transfer to send the user to an external site. Only Response.Redirect can do that.

Secondly, Server.Transfer maintains the original URL in the browser. This can really help streamline data entry techniques, although it may make for confusion when debugging.

That's not all: The Server.Transfer method also has a second parameter—"preserveForm". If you set this to True, using a statement such as Server.Transfer("WebForm2.aspx", True), the existing query string and any form variables will still be available to the page you are transferring to.

Read more here: http://www.developer.com/net/asp/article.php/3299641/ServerTransfer-Vs-ResponseRedirect.htm



标签: Fiddler