1

認証に ClientFormAuthenticationMembershipProvider を使用するように設定されたクライアントとアプリケーションがあります。クライアント側では、アプリケーションが起動すると、システムはユーザー名とパスワードの入力を求めます。サーバーはこれを受け入れるように設定されており、Web アプリケーションはアプリケーションの動作を許可することになっています。新しい環境をセットアップしている最中ですが、サーバー側で何かが機能していません (クライアントを別のサーバーに向けると、正常に機能します)。考えられるすべての詳細を入念に調べましたが、結果は同じです。ValidateUser() の呼び出しで例外がスローされます。Network Sniffer をダウンロードしましたが、Authentication_JSON_AppService.axd を呼び出そうとすると、内部で 302 メッセージが返されていることがわかります。サーバー側では、

クライアント側の構成:

FormMain.cs (プロバイダーを呼び出そうとします) から

if (!System.Web.Security.Membership.ValidateUser(null, null))
    System.Windows.Forms.Application.Exit();
else
{
       DoStartUp();
....
}

FormLogin.cs から (UserName と Pass のプロンプトが表示されます) 注: クラスは IClientFormsAuthenticationCredentialsProvider を継承します

    public System.Web.ClientServices.Providers.ClientFormsAuthenticationCredentials GetCredentials()
    {
        if (this.ShowDialog() == DialogResult.OK)
        {
            return new ClientFormsAuthenticationCredentials(
                textEditUsername.Text, textEditPassword.Text,
                false);
        }
        else
        {
            return null;
        }

    }

app.config から:

    <membership defaultProvider="ClientAuthenticationMembershipProvider">
      <providers>
        <clear />
        <add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="http://SERVERNAME/APPNAME/Authentication_JSON_AppService.axd" credentialsProvider="APPNAME.Windows.FormLogin, APPNAME.Windows" savePasswordHashLocally="False" />
      </providers>
    </membership>

サーバー側:

IIS は、このアプリケーション用に匿名認証とフォーム認証用に構成されています。(IIS 7.5、.NET 4.0、Windows Server 2008 R2 を実行しています)。サーバーには、WCF Activation および HTTP Activation 機能がインストールされています。ApplicationPool は v4.0 Framework に設定され、32 ビット アプリケーションは無効になり、Integrated PipelineMode が設定され、その他のほとんどの値はデフォルトに設定されます。

web.config ファイル:

  <system.web.extensions>
    <scripting>
      <webServices>
         <authenticationService enabled="true" />
         <roleService enabled="true" />
       </webServices>
     </scripting>
   </system.web.extensions>
     <authentication mode="Forms">
       <forms name=".MDPSApp" loginUrl="~/Connect/Login.aspx" slidingExpiration="true" timeout="600000">
       </forms>
     </authentication>
     <authorization>
       <deny users="?" />
     </authorization>
     <membership defaultProvider="XYZ">
       <providers>
         <add name="XYZ" type="APPNAME.Web.Providers.MembershipProvider, APPNAME.Web" />
       </providers>
     </membership>
 <system.serviceModel>
     <bindings>
       <wsHttpBinding>
         <binding name="DisableAutoCookieManagement" maxReceivedMessageSize="2147483647" allowCookies="false">
           <readerQuotas maxDepth="64" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
           <security mode="None" />
         </binding>
       </wsHttpBinding>
     <behaviors>
 <serviceBehaviors>
         <behavior name="APPNAME.Application.Web.Services.AgenceMaster.ServiceAgenceMasterBehavior">
           <serviceMetadata httpGetEnabled="true" />
           <serviceDebug includeExceptionDetailInFaults="true" />
           <serviceAuthorization principalPermissionMode="None">
           </serviceAuthorization>
         </behavior>
         <behavior name="APPNAME.Application.Web.Services.Agence.ServiceAgenceBehavior">
           <serviceMetadata httpGetEnabled="true" />
           <serviceDebug includeExceptionDetailInFaults="true" />
         </behavior>
       </serviceBehaviors>
     </behaviors>
 <services>
       <service behaviorConfiguration="APPNAME.Application.Web.Services.AgenceMaster.ServiceAgenceMasterBehavior" name="APPNAME.Application.Web.Services.AgenceMaster.ServiceAgenceMaster">
         <endpoint address="" binding="wsHttpBinding" bindingConfiguration="DisableAutoCookieManagement" contract="APPNAME.Services.AgenceMaster.IServiceAgenceMaster">
           <identity>
             <dns value="localhost" />
           </identity>
         </endpoint>
         <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
       </service>
       <service behaviorConfiguration="APPNAME.Application.Web.Services.Agence.ServiceAgenceBehavior" name="APPNAME.Application.Web.Services.Agence.ServiceAgence">
         <endpoint address="" binding="wsHttpBinding" bindingConfiguration="DisableAutoCookieManagement" contract="APPNAME.Services.Agence.IServiceAgence">
           <identity>
             <dns value="localhost" />
           </identity>
         </endpoint>
         <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
       </service>
     </services>
     <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
   </system.serviceModel>

APPNAME.Web.Providers.MembershipProvider クラスは System.Web.Security.MembershipProvider を拡張し、カスタム コードで ValidateUser(string username, string password) をオーバーライドします。このクラスは、シナリオ中にインスタンス化または呼び出されません。

サーバー側で何かが正しく構成されていないか、サーバーは Authentication_JSON_AppService.axd 呼び出しを適切に解決する方法を知っています (そうではないように思えます)。どんな考えや助けも大歓迎です!

4

1 に答える 1

0

これは私をばかげたものにした。FireFoxでは、WCFREST呼び出しを呼び出した*.aspxページのURLを入力すると、すべて正常に機能しました。その後、shift-reloadを実行すると、存在しないフォームのログインページにリダイレクトされる302が表示されます。

SafariとChromeの場合-シフトリロードは必要ありません。最初のロードで302で失敗します。

基本的な答えは、ASP.NETブログのAlexで見つけました。

簡単な答え:フォーム認証を削除するようにweb.configを変更します。

<modules runAllManagedModulesForAllRequests="true">
  <remove name="FormsAuthentication" />
</modules>
于 2013-01-15T20:11:09.540 に答える