2016-07-27 73 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。