MVC4 Web ロールと一連のサービス ロール (ワーカーと Web の両方) で構成される Windows Azure アプリケーションがあり、すべて June 2012 SDK を使用して構築されています。私の MVC ロールは、WIF/ACS とパッシブ リダイレクトを使用して保護されています。私のサービスは内部エンドポイント経由でのみアクセスでき、保護されていません。
通常、WIF/ACS を使用した認証と承認は正常に機能しますが、1 つのアカウントからサインアウトしてすぐにブラウザの履歴から [インデックス] ページに戻ると、再度ログインするように求められることを期待して、代わりに次のメッセージが表示されることがあります。次の YSOD:
Object reference not set to an instance of an object.
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.NullReferenceException: Object reference not set to an instance of an object.
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:
[NullReferenceException: Object reference not set to an instance of an object.]
Microsoft.IdentityModel.Configuration.ServiceConfiguration.GetCurrent() +123
Microsoft.IdentityModel.Claims.ClaimsPrincipal.CreateFromHttpContext(HttpContext httpContext, Boolean clientCertificateAuthenticationEnabled) +29
Microsoft.IdentityModel.Web.WSFederationAuthenticationModule.OnPostAuthenticateRequest(Object sender, EventArgs e) +91
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +79
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +269
最初は、これは Cookie が消去されていないためではないかと考えていましたが、驚くべきことに、MVC サイト全体がクラッシュしたようで、このエラーはどのブラウザーや他のマシンからも表示されます。私が見つけた唯一の修正は、役割を再起動することです。
パッシブ リダイレクションは web.config で設定され、STS ウィザードを使用して自動的に適用されるため、ユーザーをログアウトするときに何か問題があると思います。私のログアウトコードは次のようになります。
public ActionResult CompleteLogOut(Boolean total, String provider = "")
{
WSFederationAuthenticationModule fam = FederatedAuthentication.WSFederationAuthenticationModule;
FormsAuthentication.SignOut();
fam.SignOut(true);
if (total)
{
provider = @"logout:" + provider;
return Redirect(ConfigurationManager.AppSettings[provider]);
}
else
{
return RedirectToAction("Index");
}
}
... 'total' が true の場合、ユーザーは ID プロバイダーのログアウト ページ ( https://accounts.google.com/Logoutまたはhttps://login.live.com/login.srf? ) にリダイレクトされます。私のテスト設定では wa=wsignout1.0です。
ログアウトが「合計」の場合にのみエラーが発生していることに気付きましたが、いずれにしても断続的なエラーであるため、これが常に正しいかどうかはわかりません.
エラーをグーグルで検索するとthisがスローされますが、これはすぐには関係ないようですが、ログアウト後に WSFederationAuthenticationModule を破棄する必要があるかどうか疑問に思います。
誰かが同様の問題に遭遇したことがありますか、それとも問題が何であるかを知っている人はいますか?
更新:
「MVC サイト全体がクラッシュしたようです。このエラーはどのブラウザーからでも表示できます」 - 実際、これは正しくないと思います。2 人の別々のユーザーが、偶然にもまったく同時に同じエラーを経験しています。