Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9319893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T03:29:53+00:00 2026-06-19T03:29:53+00:00

Possibly Duplicate : NetworkError: 405 Method Not Allowed in WCF I called a REST

  • 0

Possibly Duplicate :
NetworkError: 405 Method Not Allowed in WCF

I called a REST service in jQuery AJAX POST. It works fine in IE8. But shows “NetworkError: 405 Method Not Allowed” in Firefox. I searched lot of websites but couldnt get a clear answer.

My Interface code :

[ServiceContract]
public interface IEShop
{
 [OperationContract]
 [WebInvoke(Method = "POST", UriTemplate = "/InsertDetails", BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
 string InsertDetails(EShopInputParameters EcomInput);
}

Jquery

var postCall = function () {  
var input =
{   
Userid: "123456",
partnerid: "cswp"   
};
alert(JSON.stringify(input));                            
$.ajax({                
type: "POST",
url: "http://localhost:36196/Service.svc/InsertDetails",
data: JSON.stringify(input),
contentType: "application/json",
dataType: "json",
success: function (response) {                        
alert(response);
},
error: function (xhr, status, error) {
alert(error);
}   
});
}

Service

public string InsertDetails(EShopInputParameters EShopInput)
{
try
{
command = database.GetStoredProcCommand(Data_Template.UspGetInsertDetails);
database.AddInParameter(command, Data_Template.UserID, DbType.String, EShopInput.Userid);
database.AddInParameter(command, Data_Template.PartnerID, DbType.String, EShopInput.partnerid);
database.ExecuteNonQuery(command);
return "0";
}
catch (Exception err)
{
throw err;
}      

}

Thanks in advance..

**EDIT** <br/>

From the blog http://blog.weareon.net/calling-wcf-rest-service-from-jquery-causes-405-method-not-allowed/ I added the below code. But it bypasses the “if” condition.

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", "GET, POST");
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Headers", "Content-Type, Accept, x-requested-with");
HttpContext.Current.Response.AddHeader("Access-Control-Max-Age", "1728000");
HttpContext.Current.Response.End();
}           
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-19T03:29:55+00:00Added an answer on June 19, 2026 at 3:29 am

    Here is the answer
    From this link

    Added the below code in service application. Works well in Firefox.

    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", "GET, POST");
    HttpContext.Current.Response.AddHeader("Access-Control-Allow-Headers", "Content-Type, Accept, x-requested-with");
    HttpContext.Current.Response.AddHeader("Access-Control-Max-Age", "1728000");
    HttpContext.Current.Response.End();
    }           
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Write a method rem() that takes as input a list containing, possibly, duplicate values
Possible Duplicate: Java Overload method with inherited interface I'm not positive my title is
Possible Duplicate: R: Finding patterns across multiple columns- possibly duplicated()? Dear all, Here is
Possible Duplicate: Java += operator In Java, this is not valid (doesn't compile), as
Possible Duplicate: jQuery Data vs Attr? I'm working on a project where I plan
Related (possibly duplicate) questions : How do I achieve equal height divs with HTML
Mostly dis can be possibly duplicate. But I dont know why I get this
Possible Duplicate: jquery v1.3.2 find element by attribute Is it possible to grab a
This is possibly a duplicate question, but I am unable to find the other
Possible Duplicate: Get first key in a [possibly] associative array? I have this array:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.