2015-09-08 39 views
0

我最近將我的ASP.NET應用程序切換到ASP.NET身份遠離Azure的Active Directory配置。測試這個時候本地我沒有問題,但是當我發佈到Azure中我得到以下錯誤:Azure聲明身份切換到標識

A claim of type ' http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier ' or ' http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider ' was not present on the provided ClaimsIdentity. To enable anti-forgery token support with claims-based authentication, please verify that the configured claims provider is providing both of these claims on the ClaimsIdentity instances it generates. If the configured claims provider instead uses a different claim type as a unique identifier, it can be configured by setting the static property AntiForgeryConfig.UniqueClaimTypeIdentifier.

有什麼我應該在我的Azure的一側,迄今已改變的配置?或者在我的代碼中還有其他需要的東西嗎?

回答

1

如果你不使用ACS作爲你的STS,那麼上面的錯誤幾乎告訴你需要什麼來解決這個問題。

您需要告訴MVC哪個聲明要用來唯一標識用戶。您可以通過設置AntiForgeryConfig.UniqueClaimTypeIdentifier屬性(通常位於global.asax中的App_Start中)來執行此操作。例如(假設您想使用nameidentifier作爲唯一的聲明):

AntiForgeryConfig.UniqueClaimTypeIdentifier = ClaimTypes.NameIdentifier;

protected void Application_Start() 
{ 
    AreaRegistration.RegisterAllAreas(); 

    FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); 
    RouteConfig.RegisterRoutes(RouteTable.Routes); 
    BundleConfig.RegisterBundles(BundleTable.Bundles); 

    AntiForgeryConfig.UniqueClaimTypeIdentifier = ClaimTypes.NameIdentifier; 
} 
+0

這是爲我做了什麼。謝謝! – muttley91