Network Error: 405 Method Not Allowed When Call WCF restful service using Cross Domain Ajax Jquery Call RRS feed

  • Question

  • User849221614 posted

    Hi All,

    We have made simple WCF restful service.

    For this  i have added

    1.  Project in VS2010 : WCF Service Application 

    2.  Add New Item  : Service.svc 

    and write below code in Service.cs class

    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]

    public class Service : IService
    public string GetData(int value)
    return string.Format("You entered: {0}", value);


    3. Add One interface classs 

    public interface IService

    [WebInvoke(Method = "GET",
    ResponseFormat = WebMessageFormat.Json,BodyStyle = WebMessageBodyStyle.Wrapped)]
    string GetData(int value);


    When I call this service from cross domain then i am get below error 

    Network Error: 405 Method Not Allowed.

    I am passing below parameters in Ajax json client call 

    Type = "POST";
    Url = "http://localhost:2784/jQueryWebSite/Service.svc/GetUser";
    Data = '{"Id": "' + uesrid + '"}';
    ContentType = "application/json; charset=utf-8";
    DataType = "json"; ProcessData = true;

    I have also add Below code in web config for cross domain

                    <binding name="webHttpBindingWithJsonP"
                             crossDomainScriptAccessEnabled="true" />
    Please suggest me the solution for cross domain wcf call
    Wednesday, August 14, 2013 1:32 AM


All replies

  • User849221614 posted

    Hi All,

    Finally I found solution from below Link


    My solution work fine for IE  browser  but not run on other  browser like firefox and chrome

    So i have added Code in global.ascx and it's working fine now..

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 14, 2013 5:11 AM
  • User260886948 posted


    I am very glad that you have solved your problem by yourself.

    If you have any other problem, welcome to post it in the asp.net forums.

    Best Regards,
    Amy Peng

    Thursday, August 15, 2013 12:10 AM