ASPDotNetStorefront can't load resource files after login

98 views Asked by At

In my ASPDotNetStorefront application, I simulate "fake" login - In SkinBase.cs file, in method protected override void OnPreInit(EventArgs e) I call my function with code:

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

And this code works. But when session expire and "Session Expire" - popup appears and user clicks "OK", the ASPDNSF redirects to Signin.aspx - page. In Signin.aspx page, I hid the Login-form and added "Back" - button with next code:

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

To redirect me to the previous page. But when redirects me to that page, the .css and .js files aren't loaded. In the Browser's Dev tools, the requests to these resources are: {{DOMAIN}}/SignIn.aspx?ReturnUrl={{Resource path}}, for example: {{DOMAIN}}/SignIn.aspx?ReturnUrl=%2FApp_Themes%2FSkin_1%2Fmystyles.css {{DOMAIN}}/SignIn.aspx?ReturnUrl=%2Fjscripts%2Fjquery.min.js

It looks like that these resources require authorized users. But in my web.config file I have

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

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

So, login shouldn't be required for these resources.

Thank you!

1

There are 1 answers

0
Geach On

For better performance and to take care static files requiring a login, disable static files from processing through the asp.net pipeline. By changing runAllManagedModulesForAllRequests to false in your web.config in your root folder.