[英]How to Server.Transfer from a standalone page?
I have a page in a folder on a site, and I want to Server.Transfer
to it from the domain root. 我有一个页面的网站上的文件夹中,我想Server.Transfer
从域根给它。 I tried adding a page to the root containing: 我尝试将页面添加到包含以下内容的根目录中:
Server.Transfer("~/folder1/default.aspx");
But I get a 500 error. 但是我收到500错误。 I also tried 我也试过
Server.Transfer("/folder1/default.aspx");
With the same result. 结果相同。 But when I tried Server.Transfer("default2.aspx");
但是当我尝试Server.Transfer("default2.aspx");
- another page in the root, it worked. -根目录中的另一个页面,它起作用了。
So how do I transfer to the page I want to transfer to? 那么,如何转移到要转移到的页面?
EDIT: folder1 is a web application (Asp.net) - does it matter? 编辑:folder1是一个Web应用程序(Asp.net)-有关系吗?
Yes - it matters that folder1 is a separate application in its own right. 是的-文件夹1本身就是一个单独的应用程序很重要。
Server.Transfer is only meant for transfers within your own ASP.NET application as it directly instantiates the target page and sends the response back from where it was called. Server.Transfer仅用于在您自己的ASP.NET应用程序内进行传输,因为它直接实例化目标页面并将响应从调用位置发回。 It has no way of doing this across applications. 它无法跨应用程序执行此操作。
It will be better for you to perform a simple Response.Redirect
to the /folder1/default.aspx page instead of transferring there. 最好执行一个简单的Response.Redirect
到/folder1/default.aspx页面,而不是转移到那里。
Edit: In the Page_Load of your Default.aspx (root), add 编辑:在Default.aspx(根)的Page_Load中,添加
Response.Redirect("/folder1/Default.aspx");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.