I understand they both don't change the URL that the client sees. Is there anything in them that makes one of them preferable over the other?
I'm planning to use it in the Application_BeginRequest in Global.asax, but also in regular aspx page.
Context.RewritePath() is the better option.
Server.Transfer() throws a
ThreadAbortException every time. The result of calling
For more details read the following MS articles:
Server.Transfer() does not send a HTTP 302 redirect command as
Response.Redirect() would do.
According to HttpContext.RewritePath on MSDN,
RewritePath() is used in cookieless session state.
Also, on a different subject,
Server.Execute() are very different:
Server.Execute() returns control to the initial page immediately after where it was called.
<div> test 1 <br/> <% Server.Execute("include.aspx?hello=ok"); %> test 2 <br/> </div>
content of include.aspx?hello=ok