Cross-Origin Requests (CORS) in ASP.NET Core | Getting Started With ASP.NET Core Series



Cross-Origin Requests (CORS) in ASP.NET Core | Getting Started With ASP.NET Core Series

Cross-Origin Requests (CORS) in ASP.NET Core | Getting Started With ASP.NET Core Series

Hello friends, Browser security prevents a web page from making requests to a different domain than the one that served the web page. This restriction is called the same-origin policy. The same-origin policy prevents a malicious site from reading sensitive data from another site.

Sometimes, you might want to allow other sites to make cross-origin requests to your application. This is usually when you have an API hosted independently and your different web applications talking to the API. In such scenarios, we need to enable CORS support on the API, so that the web application can call it.

In this video, let’s learn about CORS, how it works, how to enable it in ASP NET API. I will show to how to simulate a CORS error in ASP NET Single Page Application and then add the appropriate configuration to ease the browser policies using CORS.

CORS is not a security feature, It is a W3C standard to relax same-origin policy. However if configured incorrectly CORS can cause potential issues to your application. Make sure to be explicit about the origins that can interact with the API that you are building.

🔗Source Code – Source Code: https://rahulpnath.visualstudio.com/DefaultCollection/YouTube%20Samples/_git/cors
🔗Enable CORS in ASP NET Core – https://docs.microsoft.com/en-us/aspnet/core/security/cors?view=aspnetcore-3.1&WT.mc_id=AZ-MVP-5003875
🔗Migrate from ASP.NET Core 2.2 to 3.0 – https://docs.microsoft.com/en-us/aspnet/core/migration/22-to-30?view=aspnetcore-3.1&tabs=visual-studio#cors&WT.mc_id=AZ-MVP-5003875

Additional Watching
📹SINGLE PAGE APPLICATION (SPA) TEMPLATES in ASP.NET Core – https://youtu.be/mILRINbRiJM
📹DEPENDENCY INJECTION in ASP.NET Core – https://youtu.be/YR6HkvNBpX4
📹MIDDLEWARE in ASP.NET Core – https://youtu.be/5eifH7LEnGo
📹ASP NET Core Series – https://www.youtube.com/playlist?list=PL59L9XrzUa-nqfCHIKazYMFRKapPNI4sP

Come say hi! ✋
🌍 Blog – https://rahulpnath.com/
✉ Subscribe to my Newsletter – https://www.rahulpnath.com/subscribe
🐦Twitter – https://twitter.com/rahulpnath
📸Instagram – https://www.instagram.com/rahulpnath/

🎥 Recording Setup and Workflow – https://www.rahulpnath.com/blog/youtube_setup_and_workflow/
Video Edited by my wife, Parvathy 😍

Make sure to SUBSCRIBE to the channel. THANK YOU for helping me grow this channel !!

Comments are closed.