Server.Transfer的主场迎战Context.RewritePath [英] Server.Transfer vs. Context.RewritePath

查看:131
本文介绍了Server.Transfer的主场迎战Context.RewritePath的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道他们都不会改变客户端看到的URL。有没有在其中任何让其中一人比其他preferable?

我打算在的Application_BeginRequest Global.asax中使用它,而且在普通的aspx页面。

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是更好的选择。
原因:

I think Context.RewritePath is the better option. Reason:

-Server.Transfer每次抛出一个ThreadAbortException。调用到Response.End 的结果。

-Server.Transfer throws a ThreadAbortException every time. The result of calling Response.End.

看看这里:

http://support.microsoft.com/kb/312629

http://msdn.microsoft.com/en-us/library/ aa332847.aspx

更多信息:结果
Server.Transfer的不发送HTTP 302重定向命令的Response.Redirect会做。

More Information:
Server.Transfer does not send a HTTP 302 redirect command as Response.Redirect would do.

他们说这里的RewritePath在Cookie的会话状态使用。

They say here that RewritePath is used in cookieless session state.

此外,在不同的主题, Server.Transfer的使用Server.Execute 有很大的不同:

Also, on a different subject, Server.Transfer and Server.Execute are very different:

使用Server.Execute 它被调用后立即返回控制到初始页面。

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>

将输出:

测试1结果
  的 include.aspx的内容?你好=确定的结果
  测试2

test 1
content of include.aspx?hello=ok
test 2

这篇关于Server.Transfer的主场迎战Context.RewritePath的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆