I am hitting the post request to WCF service end point from my angular 7 application. On localhost, the hit goes to WCF server but when i deploy the WCF application on server then Method 405 not allowed Cors preflight error is showing in my console. Even cors are enabled in WCF application.
What's the issue? Please help me out.
Thanks in advance.
What I have tried:
public class Global : System.Web.HttpApplication
{
protected void Application_BeginRequest(object sender, EventArgs e)
{
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin", "*");
if (HttpContext.Current.Request.HttpMethod == "OPTIONS")
{
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Methods", "POST, PUT, DELETE");
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Headers", "Content-Type, Accept");
HttpContext.Current.Response.AddHeader("Access-Control-Max-Age", "1728000");
HttpContext.Current.Response.End();
}
}
}