English 中文(简体)
HTTPModule BeginRequest should us Response.Redirect or Server.Transfer
原标题:

We have a URLRewriting module that is using a Response.Redirect in the BeginRequest event method to change the destination page.

  • Would it be better to use Server.Transfer or Server.TransferRequest instead of Response.Redirect?
  • There are other HTTP Modules in the solution, will I bypass any of the other modules by using Server.Transfer or will the server begin as though it is a new request, just saving the round trip to the browser?
  • Will the client notice any differences and will the server treat the request differently in anyway?

The following questions cover the differences between redirect and transfer but not within an HTTP Module;

EDIT: HttpContext.RewritePath is also used in the module so it seems we have three techniques to move the initial Request from the original path; Redirect, Transfer, RewritePath which respectively; go back to browser, back to start of HTTP pipeline and continue processing on new path.

最佳回答

Here s the best explanation of Redirect vs Transfer vs RewritePath; http://www.developerfusion.com/article/4643/implementing-http-handlers-in-aspnet/4/

To summarise; Redirect requires roundtrip to browser, Transfer ensures the original Request object remains not the new request but has problems with Post-backs, Rewrite loses the orginal Request object but is the best for performance.

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签