Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
957 views
in Technique[技术] by (71.8m points)

asp.net - 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...