簡體   English   中英

WebAPI,MVC和IIS中具有Thinktecture.IdentityModel的CORS支持

[英]CORS support in WebAPI, MVC and IIS with Thinktecture.IdentityModel

我正在嘗試使用Thinktecture.IdentityModel來實現CORS,如以下鏈接中所述:

http://brockallen.com/2012/06/28/cors-support-in-webapi-mvc-and-iis-with-thinktecture-identitymodel/

我嘗試了Web API方法,但沒有成功。 所以我去了IIS路由。

<system.webServer>
  <modules runAllManagedModulesForAllRequests=“true“>
    <add name=“MvcCorsHttpModule“
         type=“Thinktecture.IdentityModel.Http.Cors.Mvc.MvcCorsHttpModule“/>
  </modules>
</system.webServer>

然后再次在global.asax中配置設置:

protected void Application_Start()
{
    …
    RegisterCors(MvcCorsConfiguration.Configuration);
}

private void RegisterCors(MvcCorsConfiguration corsConfig)
{
    corsConfig
        .ForResources(“Products.GetProducts”)
        .ForOrigins(“http://foo.com&#8221;)
        .AllowAll();
}

現在,它可以在我的本地主機(Windows 8,VS 2012)上運行,但是當我將其推送到產品(IIS 6)上時,它不起作用。 還有其他設置可以使其在IIS 6中運行嗎? 為什么將它在本地主機上運行,​​但當我將其推送到生產環境時卻無法運行。

您的問題與相反。

模塊在IIS6和IIS7 +中的注冊方式有所不同。

<configuration>
    <system.web>
      <httpModules>
        <add name="MvcCorsHttpModule" type="Thinktecture.IdentityModel.Http.Cors.Mvc.MvcCorsHttpModule"/>
      </httpModules>
    </system.web>
</configuration>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM