gpt4 book ai didi

javascript - ASPDotNetStorefront 登录后无法加载资源文件

转载 作者:行者123 更新时间:2023-11-28 05:29:06 24 4
gpt4 key购买 nike

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

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

并且此代码有效。但是当 session 过期和“ session 过期” - 出现弹出窗口并且用户单击“确定”时,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 文件。在 Browser 的 Dev tools 中,对这些资源的请求是:{{DOMAIN}}/SignIn.aspx?ReturnUrl={{资源路径}},例如:{{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>

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

谢谢!

最佳答案

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

关于javascript - ASPDotNetStorefront 登录后无法加载资源文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38608062/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com