1. 程式人生 > >webapi 跨域 (MVC-Web API: 405 method not allowed問題 )

webapi 跨域 (MVC-Web API: 405 method not allowed問題 )

image all div sta alt release new enable attr

使用webapi cors

1.安裝包:Install-Package Microsoft.AspNet.WebApi.Cors –IncludePrerelease

2.在webapiconfig.cs中增加如下代碼。

var cors = new EnableCorsAttribute("*", "*", "*");
            config.EnableCors(cors);

  技術分享圖片

webapi 跨域 (MVC-Web API: 405 method not allowed問題 )