简体   繁体   English

Server.Transfer是否可以跨AppDomains / Web应用程序工作?

[英]Will Server.Transfer work across AppDomains/Web Applications?

If you have two applications residing on the same server, can you use Server.Transfer to load a page in a different AppDomain/Application? 如果您有两个应用程序驻留在同一服务器上,是否可以使用Server.Transfer将页面加载到其他AppDomain / Application中?

My guess is no, because Server.Transfer() copies HttpContext.Items, among other things. 我的猜测不是,因为Server.Transfer()复制HttpContext.Items等。 To copy this data between AppDomains, would cause threading and memory sharing concerns a in a world were thread isolation is strictly enforced. 在AppDomain之间复制此数据,可能会导致线程和内存共享问题,这是严格执行线程隔离的世界。

Thoughts? 有什么想法吗?

Nope, it's not possible. 不,这是不可能的。

Server.Transfer and Server.Execute cannot be used in these scenarios. 在这些情况下,不能使用Server.TransferServer.Execute

It does not, however, copy the HttpContext.Items . 但是,它不会复制HttpContext.Items It's not copied. 它没有被复制。 The same HttpContext is reused. 相同的HttpContext被重用。

You can't use Server.Transfer() across web apps. 您不能跨Web应用程序使用Server.Transfer()。 The reason being that it actually just changes the page that the HttpHandler was going to return, rather than finishing the request and making a new one. 原因是它实际上只是更改了HttpHandler将要返回的页面,而不是完成请求并发出新请求。 It causes an extra trip to the browser, but Response.Redirect() is really the way to do it. 这会导致浏览器额外的行程,但是Response.Redirect()确实是实现此目的的方法。

Server.Transfer vs Response.Redirect Server.Transfer与Response.Redirect

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM