WCF Service Returning “Method Not Allowed”

前端 未结 9 1552
庸人自扰
庸人自扰 2020-11-27 05:04

In the process of developing my first WCF service and when I try to use it I get \"Method not Allowed\" with no other explanation.

I\'ve got my interface set up wit

相关标签:
9条回答
  • 2020-11-27 05:34

    If you are using the [WebInvoke(Method="GET")] attribute on the service method, make sure that you spell the method name as "GET" and not "Get" or "get" since it is case sensitive! I had the same error and it took me an hour to figure that one out.

    0 讨论(0)
  • 2020-11-27 05:38

    Your browser is sending an HTTP GET request: Make sure you have the WebGet attribute on the operation in the contract:

    [ServiceContract]
    public interface IUploadService
    {
        [WebGet()]
        [OperationContract]
        string TestGetMethod(); // This method takes no arguments, returns a string. Perfect for testing quickly with a browser.
    
        [OperationContract]
        void UploadFile(UploadedFile file); // This probably involves an HTTP POST request. Not so easy for a quick browser test.
     }
    
    0 讨论(0)
  • 2020-11-27 05:43

    It sounds like you're using an incorrect address:

    To access the Service I enter http://localhost/project/myService.svc/FileUpload

    Assuming you mean this is the address you give your client code then I suspect it should actually be:

    http://localhost/project/myService.svc
    
    0 讨论(0)
提交回复
热议问题