Same-origin policy
The same-origin policy is a browser security mechanism that restricts how scripts and documents interact with resources from origins that differ in scheme, host, or port.
Building Web APIs with ASP.NET Core
The same-origin policy is a browser security rule that restricts scripts from accessing resources unless their protocol, host, and port origins match.
- How it is used
- Explains why a browser-based app needs CORS to request an API hosted on another domain.
- How deep it goes
- Defines origin matching and shows CORS policy configuration without detailing browser enforcement internals.
- Examples
- Uses an Angular app requesting a board-game API on another domain and ASP.NET Core CORS policy listings.
- What you can do after
- Operate/configure it in ASP.NET Core by registering a CORS policy and enabling it through middleware or endpoints.
Read how Building Web APIs with ASP.NET Core explains same-origin policy →
ASP.NET Core in Action, 3e
The same-origin policy is a browser security restriction that limits scripts' access to resources from a different origin unless that access is explicitly permitted.
- How it is used
- Protects web APIs by restricting JavaScript requests from applications with different origins.
- How deep it goes
- Defines origin matching and demonstrates blocked URLs, then defers permission configuration to CORS.
- Examples
- Uses matching and mismatching example.com URLs plus a shopping site calling a separate product API.
- What you can do after
- Evaluate whether a JavaScript request is same-origin and recognize when CORS permission is required.
Read how ASP.NET Core in Action, 3e explains same-origin policy →
Also covered in
- Grokking Web Application Security
- Pro Angular 16
- Vanilla WebIn early access (MEAP)
- HTML5 in Action
- Pro ASP.NET Core 7, Tenth Edition
What to know first
- JavaScriptJavaScript is a high-level, dynamically typed programming language standardized as ECMAScript and used for web and general-purpose programming.
Related concepts
- CORSaddressed by · Cross-Origin Resource Sharing (CORS) is a web standard that uses HTTP headers to let servers specify which origins may access their resources through browsers.
- IndexedDBused by · IndexedDB is a browser API for asynchronously storing and querying structured data in transactional, indexed client-side databases.
- JavaScriptconfigures · JavaScript is a high-level, dynamically typed programming language standardized as ECMAScript and used for web and general-purpose programming.
- originconfigures · A web origin is the security identity defined by a resource's scheme, host, and port.
- script elementcontrasts with · A script element is an HTML element that embeds script content or references an external script resource for processing by a browser.
- browserused by · A web browser is software that retrieves, interprets, and renders web resources, executes supported web content, and enables interaction with web applications.
Questions about same-origin policy
What is same-origin policy?
The same-origin policy is a browser security mechanism that restricts how scripts and documents interact with resources from origins that differ in scheme, host, or port.
Which Manning books explain same-origin policy?
Building Web APIs with ASP.NET Core and ASP.NET Core in Action, 3e.
What should I know before learning same-origin policy?
Manning books that teach same-origin policy usually introduce JavaScript first.
What is the difference between same-origin policy and script element?
The same-origin policy is a browser security mechanism that restricts how scripts and documents interact with resources from origins that differ in scheme, host, or port. A script element is an HTML element that embeds script content or references an external script resource for processing by a browser.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

