Posts

Showing posts with the label CORS

CORS - ajax POST Request, Handle 405 method not found

Today, when I published WCF service and website on UAT server, I started getting 405 (Method not allowed) error on ajax POST requests. After searching a lot on internet, I finally fixed the issue. I am hoping that my findings will save others time. We can fix this issue using following different options Add following code in WCF global.asax file. Publish the code and deploy it. 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( "Cache-Control" ,  "no-cache" );          HttpContext .Current.Response.AddHeader( "Access-Control-Allow-Methods" ...