c# - WebServiceHost returning 405 not allowed on GET in .NET4.0 -


this simple webservicehost works when compile .net3.5 not in 4.0 access browser url http:// mycomputer:8081/svc/helloworld

the 3.5 version returns the"hello world! @ <time>" string, 4.0 version returns - 405 not allowed.

does know why?

i'm using .net4.0 on win7 sp1 64bit machine

using system; using system.web.services; using system.servicemodel; using system.servicemodel.web; using system.collections.generic; using system.runtime.serialization;  [servicecontract] public interface imyservice {     [operationcontract]     [webget(uritemplate = "helloworld")]     string hellworld(); }  public class myservice : imyservice {     public string hellworld()     {         return "hello world! @ " + datetime.now.tostring("s");     } }  public class myclass {      public static void main()     {         string mycomputer = "mycomputer";         string mysvcuri = "http://" + mycomputer + ":8081/svc";         uri[] baseaddresses = new uri[] { new uri(mysvcuri) };          webservicehost hostvisits = new webservicehost(typeof(myservice), baseaddresses);         basichttpbinding binding = new basichttpbinding();         hostvisits.addserviceendpoint(typeof(imyservice), binding, "myservice");          hostvisits.open();          console.writeline("service host started, press key exit");         console.readkey();     } } 

nothing written eventlog.

just remove these 2 lines. work.

basichttpbinding binding = new basichttpbinding(); hostvisits.addserviceendpoint(typeof(imyservice), binding, "myservice"); 

Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -