C# 在虚拟路径'/Login.aspx';映射到另一个应用程序,这是不允许的
我遇到了一个问题(asp.net 3.5): 当导航到它时,将我重定向到不允许登录的位置(因为ReturnUrl=%2f) 为了解决这个问题,我更改了global.aspx应用程序\u BeginRequest:C# 在虚拟路径'/Login.aspx';映射到另一个应用程序,这是不允许的,c#,asp.net,C#,Asp.net,我遇到了一个问题(asp.net 3.5): 当导航到它时,将我重定向到不允许登录的位置(因为ReturnUrl=%2f) 为了解决这个问题,我更改了global.aspx应用程序\u BeginRequest: protected void Application_BeginRequest(object sender, EventArgs e) { // redirect user from http to https if (!Request
protected void Application_BeginRequest(object sender, EventArgs e)
{
// redirect user from http to https
if (!Request.IsLocal && !Request.IsSecureConnection)
{
string redirectUrl = Request.Url.ToString().Replace("http:", "https:");
Response.Redirect(redirectUrl);
}
// I HAVE ADDED THESE LINES!!!!!!!!!!!!!!
if (Request.AppRelativen aCurrentExecutionFilePath == "~/")
HttpContext.Current.RewritePath("Login.aspx");
}
现在,它似乎工作完美,但不是
问题是我有另一个虚拟应用程序,可以通过
如果我直接进去,一切都好
但是如果我输入,它会显示“虚拟路径'/Login.aspx'映射到另一个应用程序,这是不允许的。”
- 如果我使用它,它会给我一个错误
- 如果我使用它,它不会给我一个错误并且Login.aspx被加载
- 我还尝试更改global.aspx: HttpContext.Current.RewritePath(“*~/*Login.aspx”); 但在这种情况下,当我在前一个应用程序中认为我在而不是虚拟应用程序中时
您如何处理这个问题?也许可以这样做,以逻辑方式而不是物理文件
//-----------------------------------------------------------------------------------
// Name: RegisterRoutes
// Purpose: Register the routes for the site.
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("admin/errorlog.axd/{*pathInfo}");
routes.MapRoute(
"Base", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Base", action = "Main", id = UrlParameter.Optional } // Parameter defaults
);
}
//-----------------------------------------------------------------------------------
// Name: Application_Start
// Purpose: The application start event handler.
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
RegisterGlobalFilters(GlobalFilters.Filters);
RegisterRoutes(RouteTable.Routes);
InitSquishIt();
}