I would like to enable existing MVC controllers (from ASP.NET Core/Kestrel server) to wrap messages as JSONP so they can be accessible cross-domain from browser. What are my options?
JSONP is pretty much deprecated, since most frameworks and servers support CORS, which makes JSONP obsolete (it doesn't work well with anything other then GET requests).
// ConfigureServices
services.AddCors(options =>
{
options.AddPolicy("AnyOrigin", builder =>
{
builder
.AllowAnyOrigin()
.AllowAnyMethod();
});
});
// Configure
app.UseCors("AnyOrigin");
This will basically allow ajax call from any domain. If you need more fine-grained control over domains and actions, check out the official docs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With