|
Статистика |
Онлайн всего: 3 Гостей: 3 Пользователей: 0 |
|
Блог |
Главная » 2015 » Июль » 5 » IIS 7.5+ Access-Control-Allow-Origin JS
12:39 IIS 7.5+ Access-Control-Allow-Origin JS |
Similar error: xmlhttprequest cannot load no 'access-control-allow-origin'
Added in Web.config File:
<system.webServer> <httpProtocol> <customHeaders> <add name="Access-Control-Allow-Origin" value="*" /> <add name="Access-Control-Allow-Headers" value="Origin, X-Requested-With, Content-Type, Accept" /> <add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE, OPTIONS" /> </customHeaders> </httpProtocol> </system.webServer>
If it don't work, use next variant:
1. Install CORS
Open Tools>NuGet Package Manager>Package Manager Console and paste Install-Package Microsoft.AspNet.WebApi.Cors
2. Add option in config file After installation is complete, add in Register function in file WebApiConfig.cs (App_Start/WebApiConfig.cs) next string
... config.EnableCors(); ...
3. Fixed Controller Add next string in your controller
using System.Web.Http.Cors;
and
[EnableCors(origins: "http://mywebclient.azurewebsites.net", headers: "*", methods: "*")]
|
Просмотров: 1696 |
Добавил: Aleksandr
| Рейтинг: 0.0/0
|
Используя изложенную информацию, Вы соглашаетесь со следующими условиями.
|
|
Календарь |
« Июль 2015 » | Пн | Вт | Ср | Чт | Пт | Сб | Вс | | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |
|
|
|
|
|