When should I use Server.Transfe开发者_JS百科r()
method?
What is the advantage of using this method?
You could use Server.Transfer
to execute some other server side page without changing the address on the client and without an additional redirect which is what Response.Redirect
does.
Server.Transfer
allows you to redirect a request on the server-side to another resource on that server. This differs from Response.Redirect
which redirects the client to another resource.
This means that processing of the requested resource is redirected to another existing resource. For example, you could have the request:
http://mydomain.com/users/100032
be handled by another resource on the server:
http://mydomain.com/users/100032/details
Server.Transfer
will have the effect of both URLs returning the same response.
This differs from Response.Redirect
, which has the effect of telling the client's browser "the resource you are requesting is at a different URL". In this case, the client's browser will make a new request to the URL and the client will see the URL change in their address bar to reflect this.
精彩评论