如何从一个独立的页面Server.Transfer的? [英] How to Server.Transfer from a standalone page?

查看:117
本文介绍了如何从一个独立的页面Server.Transfer的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网站的文件夹中的网页,我想 Server.Transfer的将其从域根。我尝试添加一个页面,包含根:

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");

但我得到一个500错误。我也试过

But I get a 500 error. I also tried

Server.Transfer("/folder1/default.aspx");

使用相同的结果。
但是,当我试图 Server.Transfer的(default2.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?

编辑:文件夹1是一个Web应用程序(Asp.net) - 这很重要。

folder1 is a web application (Asp.net) - does it matter?

推荐答案

是 - 它是重要的folder1是在自己的权利单独的应用程序。

Yes - it matters that folder1 is a separate application in its own right.

Server.Transfer的只是针对传输,因为它直接实例化目标页面,并从那里被称为响应发送回自己的ASP.NET应用程序中。它没有这样做跨应用程序的方式。

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.

这将是更好地为您进行一个简单的的Response.Redirect 来的/folder1/default.aspx页面,而不是转移那里。

It will be better for you to perform a simple Response.Redirect to the /folder1/default.aspx page instead of transferring there.

编辑:在您的Default.aspx(根)的Page_Load中添加

In the Page_Load of your Default.aspx (root), add

Response.Redirect("/folder1/Default.aspx");

这篇关于如何从一个独立的页面Server.Transfer的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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