The remote server returned an error: (405) Method Not Allowed.

    General discussion

  • I am attempting to run a wcf service from IIS 7.5 on Windows 7.   When I browse the .svc file from IIS the Service Page appears in the browser.

    But if I attempt to access the service from a Console or a WebApplication I get the following error.  I have tried following the instructions on  

    Ran aspnet_regiis -enable
    Ran "%WINDIR%\Microsoft.Net\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe" -r
    verified existence of 
    svc-Integrated Managed Handler 
    verified existence of svc-ISAPI-2.0 Script Map

    What else could it be?

    Below is the Fiddler Message:

    [WebException]: The remote server returned an error: (405) Method Not Allowed.
       at System.Net.HttpWebRequest.GetResponse()
       at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
    [ProtocolException]: The remote server returned an unexpected response: (405) Method Not Allowed.

    Server stack trace: 
       at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory factory, WebException responseException, ChannelBinding channelBinding)
       at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
       at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
       at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
       at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

    Exception rethrown at [0]: 
       at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
       at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
       at ShippingPackagingService.IShippingPackagingService.GetRate(ShippingPackagingRequest request)
       at ShippingPackagingService.ShippingPackagingServiceClient.GetRate(ShippingPackagingRequest request) in c:\Windows\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\root\bbd569ba\cb5077d2\App_WebReferences.9m-tjimf.0.cs:line 496
       at _Default.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\WCFTestSite\Default.aspx.cs:line 15
       at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
       at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
       at System.Web.UI.Control.OnLoad(EventArgs e)
       at System.Web.UI.Control.LoadRecursive()
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    [HttpUnhandledException]: Exception of type 'System.Web.HttpUnhandledException' was thrown.
       at System.Web.UI.Page.HandleError(Exception e)
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
       at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
       at System.Web.UI.Page.ProcessRequest()
       at System.Web.UI.Page.ProcessRequest(HttpContext context)
       at ASP.default_aspx.ProcessRequest(HttpContext context) in c:\Windows\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\root\bbd569ba\cb5077d2\App_Web_cbhvd_mw.0.cs:line 0
       at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
       at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)


    Thursday, October 18, 2012 12:58 AM

All replies

  • Hi,

    The error message indicates that it throw an exception  at _Default.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\WCFTestSite\Default.aspx.cs:line 15, could you please share the code with us?

    By the way, does it work if you just access a hello world aspx page or WCF service?


    Leo Tang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, October 19, 2012 2:13 AM
  • Thanks for the response.

    Yes, this wcf error is happening on the client.  I can Browse the .svc file on the server from IIS Manager.    I can view the wsdl in the browser.  No problem there.

    This error is happening on the client with a standard "Hello World" operation or an actual application service operation.  I do not have the actual code in front of me right now.  But I am doing the standard.  

    WCFServiceClient client = new WCFServiceClient();

    The error occurs on client.PerformOperation();

    I get the same issue whether the client is a console program or a page.

    The service is located outside the IIS DefaultWebsite Directory

    WAS is not enabled.  To my knowledge WAS is only required if http(s) is not used.


    Friday, October 19, 2012 7:05 AM
  • Hi,

    Could you please enable Failed Request Tracing to determine the root cause?

    Troubleshooting Failed Requests Using Tracing in IIS 7


    Leo Tang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, October 22, 2012 3:57 AM
  • Thanks Leo,

    I got frustrated and just recreated the solution.  For some reason it worked.  What bug or glitch occurred, I do not know.

    But I had to move forward.

    Thanks again,

    Monday, October 29, 2012 2:49 PM
  • Please share server and client config files for more details

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, October 29, 2012 9:22 PM