I have a page in a folder on a site, and I want to Server.Transfer
to it from the domain root. I tried adding a page to the root containing:
Server.Transfer("~/folder1/default.aspx");
But I get a 500 error. I also tried
Server.Transfer("/folder1/default.aspx");
With the same result.
But when I tried 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?
Yes - it matters that folder1 is a separate application in its own right.
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. 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.Edit: In the Page_Load of your Default.aspx (root), add