2013-02-16 125 views
2

当我导航到https://mypage.net时,我有一个问题登录(因为ReturnUrl =%2f)。表单身份验证虚拟路径'/Login.aspx'映射到另一个应用程序,这是不允许的

为了解决这个问题我已经改变了我global.aspx的Application_BeginRequest:

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

现在似乎工作完美,但不是。

的问题是,我有另外一个虚拟应用程序如果我直接进入https://mypage.net/QA/login.aspx那么一切都很好就是通过 https://mypage.net/QA 访问。

但是,如果我进入https://mypage.net/QA然后它说:“虚拟路径‘/Login.aspx’映射到另一个应用程序,这是不允许的。”

你怎么处理?

回答

0

也许做这样的事情路由逻辑的事情,而不是物理文件

http://msdn.microsoft.com/en-us/library/cc668201%28v=vs.100%29.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(); 
    } 
相关问题