2016-07-27 71 views
0

在我ASPDotNetStorefront申請後,我模仿「假」登錄 - 在SkinBase.cs文件,在方法protected override void OnPreInit(EventArgs e) 我把我的函數代碼:ASPDotNetStorefront無法加載資源文件登錄

public void SetTempUserForNonLoginStore() 
    { 
     if (AppLogic.StoreID() == 2) //store which doesn't need login 
     { 
      string path = HttpContext.Current.Request.Url.AbsolutePath.ToLower(); 
      if (path.Contains("signin.aspx") == false) 
      { 

       m_ThisCustomer = new Customer(TempCustomerID); 
       AppLogic.ExecuteSigninLogic(0, m_ThisCustomer.CustomerID); 
       string cookieUserName = m_ThisCustomer.CustomerGUID.ToString(); 

       FormsAuthentication.SetAuthCookie(cookieUserName, true); 
       m_ThisCustomer.ThisCustomerSession.UpdateCustomerSession(null, null); 
       HttpCookie authCookie = Response.Cookies[FormsAuthentication.FormsCookieName]; 
       if (authCookie != null && !AppLogic.AppConfigBool("GoNonSecureAgain")) 
       { 
        authCookie.Secure = AppLogic.UseSSL() && AppLogic.OnLiveServer(); 
       } 
      } 
     } 
    } 

而且此代碼工作。但是當會話過期並且「會話過期」 - 彈出窗口出現並且用戶點擊「確定」時,ASPDNSF重定向到Signin.aspx頁面。在Signin.aspx頁,我躲在登錄形式,並添加「返回」 - 按鈕,下面的代碼:

protected void btn_GoBack_Click(object sender, EventArgs e) 
    { 
     string returnURLParam = HttpContext.Current.Request["ReturnUrl"]; 
     if (string.IsNullOrWhiteSpace(returnURLParam)) 
     { 
      returnURLParam = "~/"; 
     } 
     Response.Redirect(returnURLParam); 
    } 

要我重定向到前一頁。但是,當將我重定向到該頁面時,不會加載.css和.js文件。在瀏覽器的開發工具,請求對這些資源有: {{DOMAIN}}/SignIn.aspx?ReturnUrl={{Resource path}}, 例如: {{DOMAIN}}/SignIn.aspx?ReturnUrl=%2FApp_Themes%2FSkin_1%2Fmystyles.css {{DOMAIN}}/SignIn.aspx?ReturnUrl=%2Fjscripts%2Fjquery.min.js

看起來,這些資源需要授權用戶。但在我的web.config文件我有

<location path="jscripts"> 
<system.web> 
    <authorization> 
    <allow users="*" /> 
    </authorization> 
</system.web> 

<location path="App_Themes"> 
    <system.web> 
     <authorization> 
     <allow users="*" /> 
     </authorization> 
    </system.web> 
    </location> 

所以,登錄不應該需要這些資源。

謝謝!

回答

0

爲了獲得更好的性能並關注需要登錄的靜態文件,請禁用通過asp.net管道進行處理的靜態文件。通過在您的根文件夾的web.config中將runAllManagedModulesForAllRequests更改爲false。