Last post Jul 18, 2017 02:17 PM by Rithu_dev
Jul 17, 2017 04:26 AM|Rithu_dev|LINK
What is the most preferred way to implement the CORS( Cross Origin Policy ) in ASP.Net Core MVC Application ? If we alter request/response headers is it enough or do we have any code level implementation to achieve this ?
Jul 17, 2017 06:35 AM|sakthivel0531|LINK
I would recommend to create different CORS policies for different domain based on the requirement
Here's an example. I have created two policy, first one for Google domain and another one for any domain can access only my get methods NOT post methods.
public void ConfigureServices(IServiceCollection services)
cfg.AddPolicy("GooglePolicy", bldr =>
cfg.AddPolicy("AnyGet", bldr =>
And you can enable CORS at your controller level like this. Any client can access your Get methods of Home Controller.
Public Class HomeController : BaseController
Jul 18, 2017 02:17 PM|Rithu_dev|LINK
Thank you for your update !