在我的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();
}
}
}
}这段代码是有效的。但是当会话过期和“会话过期”弹出窗口出现时,用户单击“确定”,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>因此,这些资源不应该需要登录。
谢谢!
发布于 2016-07-29 03:10:23
为了获得更好的性能并注意需要登录的静态文件,请禁止通过asp.net管道处理静态文件。通过在根文件夹的web.config中将runAllManagedModulesForAllRequests更改为false。
https://stackoverflow.com/questions/38608062
复制相似问题