November 2015
Intermediate to advanced
152 pages
2h 46m
English
We can also restrict the HTTP methods in CORS. This can be achieved by supplying a comma separated list of HTTP methods that are allowed to the [EnableCors] attribute's methods parameter as given in the following:
[EnableCors(origins: "http://localhost:53870", headers: "*", methods: "get,post")] public class ContactsController : ApiController { IEnumerable<Contact> contacts = new List<Contact> { new Contact { Id = 1, Name = "Steve", Email = "steve@gmail.com", Mobile = "+1(234)35434" }, new Contact { Id = 2, Name = "Matt", Email = "matt@gmail.com", Mobile = "+1(234)5654" }, new Contact { Id = 3, Name = "Mark", Email = "mark@gmail.com", Mobile = "+1(234)56789" } }; // GET: api/Contacts public IEnumerable<Contact> ...Read now
Unlock full access