既存のデータベースの上に ASP.NET の認証と承認を実装しようとしています。データを取得するために Web サービスを呼び出す Web サイトがあります。Web サービスを使用するには、ユーザー名とパスワードを入力する必要があります。そのことを踏まえて、IIdentity と IPrincipal を実装して、暗号化されたパスワードを保存し、Web サービス呼び出しの実行時にそれを提供できるようにすることにしました。将来的には、asp.net の組み込みセキュリティをさらに使用する可能性があるため、メンバーシップとロール プロバイダーを実装し、必要なもの (ValidateUser と GetRoles) だけをオーバーライドします。ただし、メンバーシップ プロバイダーのおかげでユーザーを検証した後実装 必要に応じてパスワードを取得できるように、独自の CustomIdentity を Context.User に設定しています。
ユーザーがページへのアクセスを許可されている限り、完全に機能しています。ただし、ユーザーが拒否されると、AccessDeniedException をスローする代わりに、フレームワークは CustomIdentity でシリアライゼーション例外をスローします。このリンク に詳細が記載されている完全に類似した動作を見つけましたが、回答は投稿されていません。
私の例外は、上記のリンクとまったく同じです
Type is not resolved for member'CW.CustomAuthentication.CWIdentity,CW.CustomAuthentication, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Runtime.Serialization.SerializationException: Type is not resolved for member 'CW.CustomAuthentication.CWIdentity,CW.CustomAuthentication, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[SerializationException: Type is not resolved for member 'CW.CustomAuthentication.CWIdentity,CW.CustomAuthentication, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.]
Microsoft.VisualStudio.WebHost.Connection.get_RemoteIP() +0
Microsoft.VisualStudio.WebHost.Request.GetRemoteAddress() +65
System.Web.HttpRequest.get_UserHostAddress() +18
System.Web.HttpRequest.get_IsLocal() +13
System.Web.Configuration.CustomErrorsSection.CustomErrorsEnabled(HttpRequest request) +86
System.Web.HttpContext.get_IsCustomErrorEnabled() +42
System.Web.Configuration.UrlAuthFailedErrorFormatter.GetErrorText(HttpContext context) +16
System.Web.Security.UrlAuthorizationModule.WriteErrorMessage(HttpContext context) +29
System.Web.Security.UrlAuthorizationModule.OnEnter(Object source, EventArgs eventArgs) +8777783
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +68
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75
メンバーシップとカスタム IIdentity および IPrincipal を同時に使用することは正しいですか? そうでない場合、メンバーシップ プロバイダーとロール プロバイダーを使用する場合、パスワードやその他のユーザーデータなどのプロパティをどこに追加すればよいですか?
よろしくお願いします、
ステファン・エルブレック