You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In my ASP.NET Core 3.0 Web API project I have enabled CORS as follows:
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
readonly string MyAllowSpecificOrigins = "_myAllowSpecificOrigins";
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.RegisterDbContext(Configuration);
services.AddCors(options =>
{
options.AddPolicy(MyAllowSpecificOrigins,
builder =>
{
builder.WithOrigins("https://localhost:44367",
"http://www.contoso.com")
.AllowAnyHeader()
.AllowAnyMethod();
});
});
services.AddControllers();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseHttpsRedirection();
app.UseRouting();
app.UseCors(MyAllowSpecificOrigins);
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
But I am always getting HTTP 500 without hitting controller method.
@pranavkm Thank you for telling this. I have fixed the issue after inspecting the StackTrace and this was not related to ASP.NET Core 3.0 CORS Settings.
ghost
locked as resolved and limited conversation to collaborators
Dec 2, 2019
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
In my ASP.NET Core 3.0 Web API project I have enabled CORS as follows:
But I am always getting HTTP 500 without hitting controller method.
HTTP 500 if request to a CORS-enabled endpoint is requested without an origin header is a similar issue and it is marked as Closed Done!
Then why I am receiving this same error?
The text was updated successfully, but these errors were encountered: