asp.net-web-apithinktecture-ident-model

Asp.net Webapi CORS with Thinktecture.IdentityModel


I am looking into resolviong Asp.net Webapi CORS issue with Thinktecture.Identitymodel as described in this URL http://brockallen.com/2012/06/28/cors-support-in-webapi-mvc-and-iis-with-thinktecture-identitymodel/

I am using VS2012 with .Net 4.5 I am coming across a couple of problems here:

1) This is the error I am coming across when i make a request

Attempted to access an element as a type incompatible with the array 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. System.ArrayTypeMismatchException: Attempted to access an element as a type incompatible with the array.

[ArrayTypeMismatchException: Attempted to access an element as a type incompatible with the array.]
System.Collections.Generic.List`1.Insert(Int32 index, T item) +62
Galaxy.CorsConfig.RegisterCors(HttpConfiguration config) +99
Galaxy.WebApiApplication.Application_Start() +377

[HttpException (0x80004005): Attempted to access an element as a type incompatible with the array.]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +12864673
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +175
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +304
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +404
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +475

[HttpException (0x80004005): Attempted to access an element as a type incompatible with the array.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12881540 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +12722601

My application pool is pointing to Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.17929

2)My second question is after doing things as mentioned in WebApi. Do i still need to add HTTPmodule for IIS?

Its should be very easy to get going with this. I don't know what I am missing here. Any pointers are highly appreciated.

Thanks.


Solution

  • I figured out that I had a version mismatch of assemblies . My actual project was in .Net 4.0 and Thinktecture was in .Net 4.5 .

    Once i fixed that it worked.