首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ASPDotNetStorefront无法在登录后加载资源文件

ASPDotNetStorefront无法在登录后加载资源文件
EN

Stack Overflow用户
提问于 2016-07-27 16:46:20
回答 1查看 76关注 0票数 0

在我的ASPDotNetStorefront应用程序中,我模拟“假”登录SkinBase.cs文件,在protected override void OnPreInit(EventArgs e)方法中,我用代码调用我的函数:

代码语言:javascript
复制
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页面中,我隐藏了登录表单,并添加了带有下一步代码的“后退”按钮:

代码语言:javascript
复制
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文件中

代码语言:javascript
复制
<location path="jscripts">
<system.web>
  <authorization>
    <allow users="*" />
  </authorization>
</system.web>

代码语言:javascript
复制
<location path="App_Themes">
    <system.web>
      <authorization>
        <allow users="*" />
      </authorization>
    </system.web>
  </location>

因此,这些资源不应该需要登录。

谢谢!

EN

回答 1

Stack Overflow用户

发布于 2016-07-29 03:10:23

为了获得更好的性能并注意需要登录的静态文件,请禁止通过asp.net管道处理静态文件。通过在根文件夹的web.config中将runAllManagedModulesForAllRequests更改为false。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38608062

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档