2013-02-16 118 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(); 
    } 
相關問題