Skip to content

Instantly share code, notes, and snippets.

@PradeepLoganathan
Last active June 29, 2020 23:23
Show Gist options
  • Select an option

  • Save PradeepLoganathan/67ec9c468a0b61efec75728ebbe53911 to your computer and use it in GitHub Desktop.

Select an option

Save PradeepLoganathan/67ec9c468a0b61efec75728ebbe53911 to your computer and use it in GitHub Desktop.
asp.net core controller with enable cors attribute
[ApiController]
[Route("api/[controller]")]
[Produces("application/json")]
[AllowAnonymous]
[EnableCors(CORSPolicies.PublicApi)]
public class PublicApiControllerBase : ControllerBase
{
[DisableCors]
[HttpGet]
public ActionResult<IEnumerable<string>> Get()
{
return new string[] { "hello", ".net Core 3.1" };
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment