Click here to Skip to main content
15,867,756 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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();
}

}
}
Posted
Comments
[no name] 8-May-19 15:13pm    
https://www.codeproject.com/Articles/845474/Enabling-CORS-in-WCF
nrjtrn 9-May-19 0:32am    
Hey Gerry , I tried that but when I deploy my WCF application on server then POST requests are not working only GET requests are working . I can provide you more information about this .

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900