LoginSignup
2
4

More than 5 years have passed since last update.

ASP.NET(C#)でクロスドメインに対応する

Last updated at Posted at 2015-06-07

System.Web.Http.corsをNuGet。
WebConfigに、Customheaderを追加すればよいだけ。

WebApiConfig.cs
using System.Web.Http;

namespace t2tr
{
    public static class WebApiConfig
    {
        public static void Register(HttpConfiguration config)
        {
            config.EnableCors();
        }
    }
}
Controllers.xxxController.cs
    [EnableCors(origins: "*", headers: "*", methods: "*")]
    public class XxxController : ApiController
    {
    }

2
4
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
4