我期待到在此URL http://brockallen.com/2012/06/28/cors-support-in-webapi-mvc-and-iis-with-thinktecture-identitymodel/Asp.net的WebAPI CORS與Thinktecture.IdentityModel
我使用VS2012與.NET 4.5 我來描述Thinktecture.Identitymodel resolviong Asp.net的WebAPI CORS問題跨越幾個問題這裏:
1)這是一個跨當我提出請求我來誤差
試圖訪問一個元素作爲一種類型的與陣列不相容執行當前的 Web請求期間發生未處理的異常。請查看堆棧跟蹤以獲取有關 錯誤以及源代碼位置的更多信息。 System.ArrayTypeMismatchException:試圖訪問元素,作爲與數組不兼容的 類型。
[ArrayTypeMismatchException:試圖訪問一個元素作爲一種類型 與陣列不相容。]
System.Collections.Generic.List`1.Insert(的Int32索引,T項)62
Galaxy.CorsConfig。 RegisterCors(HttpConfiguration配置)99
Galaxy.WebApiApplication.Application_Start()377[HttpException(0X80004005):試圖訪問一個元素作爲一種類型 與陣列不相容]
System.Web.HttpApplicationFactory .EnsureAppStartCalledForIntegratedMode (HttpContext的 上下文,HttpApplication的應用)12864673個
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr的 appContext,HttpContext的上下文中,MethodInfo的[]處理程序)175
System.Web.HttpApplication.InitSpecial(HttpApplicationState狀態, MethodInfo的[ ]處理程序,IntPtr的appContext,HttpContext的上下文中)304
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr的 appContext,HttpContext的上下文中)404
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr的 appContext)475[HttpException(0X80004005):試圖訪問一個元素作爲一種類型 與陣列不相容]
System.Web.HttpRuntime.FirstRequestInit(HttpContext的上下文)12881540 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext的上下文) +159 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest WR,HttpContext的背景下)12722601
我的應用程序池,指向Microsoft .NET Framework版本:4.0.30319; ASP.NET版本:4.0.30319.17929
2)我的第二個問題是在做WebApi中提到的事情之後。我還需要爲IIS添加HTTPmodule嗎?
它應該很容易得到這個。我不知道我在這裏錯過了什麼。 任何指針,高度讚賞。
謝謝。
我得到相同的錯誤,雖然我嘗試了WebApiSecurity示例。當我運行示例它工作正常。當我創建一個新的項目,將其更改爲4.5,並嘗試將MessageHandler添加到AuthenticationHandler我得到相同的錯誤「試圖訪問元素作爲與數組不兼容」。只是無法找到我的項目和樣本中的任何差異。 –