Category: ASP.NET/MVC/WebAPI

  • Enable CORS in ASP.NET Core Web API

    Hello friends, As we know that in Web API, CORS is by default disabled due to security reasons. and hence if a client tries to access API in different server and port, you can end up with error as “Origin http://localhost:xxxx is not allowed by Access-Control-Allow-Origin“ To enable it in ASP.NET Core Web API, there…

  • Changing default route in ASP.NET MVC

    Hello friends, As we know that ASP.NET MVC by default takes following setting available in RouteConfig file (under App_Start folder). routes.MapRoute( name: “Default”, url: “{controller}/{action}/{id}”, defaults: new { controller = “Home”, action = “Index”, id = UrlParameter.Optional } ); This means when you run the application, Home controller will be invoked and it’s Index method will be executed by taking parameter id (if any). you can change…