0

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 Expire" - ポップアップが表示され、ユーザーが "OK" をクリックすると、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>

したがって、これらのリソースにログインする必要はありません。

ありがとうございました!

4

1 に答える 1

0

パフォーマンスを向上させ、ログインが必要な静的ファイルを処理するには、asp.net パイプラインを介した静的ファイルの処理を無効にします。ルート フォルダーの web.config で runAllManagedModulesForAllRequests を false に変更します。

于 2016-07-28T19:10:23.103 に答える