(Resolved and a Question) WCF Service response "HTTP/1.1 400 Bad Request" on shared hosting <aka Safari/Chrome:Blank Page, FF:XML Parsing Error, IE:The webpage cannot be found, Opera:Invalid Address>


  • Hi,


    This is both information to those experiencing the issue and a question.

    edit: The question is why does dropping "www." from the URL cause this error when a website running at the same address can be referenced without "www.".

    I recently reproduced this problem using a trivial WCF service (the one from after resolving the usual config issues one faces moving a service from local IIS to shared hosting.


    The problem was the following response (from fiddler) upon checking the url in browser. In searching the web for posts on the topic I found a number of unresolved issues pointing to the same problem in addition to the posts where the usual shared hosting config issues fix them up.

    HTTP/1.1 400 Bad Request
    Server: Microsoft-IIS/7.0
    X-Powered-By: ASP.NET
    Date: Tue, 17 Aug 2010 00:27:52 GMT
    Content-Length: 0

    In Safari/Chrome this manifests as a blank page.

    In IE you get "The webpage cannot be found".

    In FF you get "XML Parsing Error: no element found Location: http://................ Line Number 1, Column 1:" (which I saw in numerous unresolved posts on the web - feel free to backlink a possible solution)

    In Opera you get "Invalid Address"

    I was scratching my head regarding this for a while, then I thought to try putting in the "www." which I was previously omitting from my url for no particular reason.

    Problem solved.

    I can now see the normal output in the browser and interact with the service via WCF Test Client.


    So the question is :

    Why does this make a difference to the hosted WCF service when I know it does not make a difference for browsing to the website hosted at the same address? With or without the "www." I can browse to the website at the same domain, hosted on the same account.


    So far I've tested this repro on a GoDaddy service. I may try some others later.


    Also, if you happen to know - I'd be interested to know what features are likely to make my WCF services need full trust rather than medium trust. And any thoughts you have on whether it is a good idea to utilise such features (in context of least priv ideology).




    Tuesday, August 17, 2010 1:32 AM

All replies

  • Summarised the question at the beginning of the post so it's easier to find at a glance.
    Wednesday, August 18, 2010 1:25 AM
  • Hi Trees,

    The problem you mentioned( service connection issue when using url with www and w/o www ) is likely a DNS server resolving issue. When you use a like hostname in TCP/IP based network protocol layers, it will call DNS server to resolve the actual IP address of the target host machine. Here are some threads discussing on such topic:

    #How to resolve my domain URL without WWW?

    #Resolve domain without www prefix

    If the DNS server in your local environment is windows server based, you can try posting the issue in windows server forums for more ideas:

    #Network Infrastructure Servers

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Wednesday, August 18, 2010 6:12 AM
  • Thanks very much for the reply Steven, I'll have a read through the links you've posted.

    Do you maintain this assessment even in light of the DNS server being capable of resolving the URLs with and without www for the domain when the website on the same domain and hosting account is visited.

    To clarify:

    www and w/o www works for URL's pointing at the domain's website... ie and both load the website perfectly.

    w/o www does NOT work for URL's pointing to this test wcf service. ie only works.


    Also relevant, until I got the web.config setup right, I was getting debug output from the WCF service telling me things like I need to setup build providers, resolve duplicate schemes and the like. This sounds like up until I sorted out WCF configuration issues, the client and the host were having a conversation through the without www URL.


    For these reasons I've been under the impression somehow the servicing infrastructure at the host is playing a part in the result.

    Wednesday, August 18, 2010 6:24 AM
  • Thanks for reply Trees,

    You just remind me of a setting which is about the site binding for WCF service hosted in web application in IIS. By default, a WCF service can only accept requests targeting a single binding address(include protocol schema and host header(or IP)).  From .NET 4.0, there is a "multipleSiteBindingsEnabled" option under the <servieHostEnvironment> setting that can enable WCF service to listen on multiple site bindings:


    You can try turning this property on to see whether it helps.

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by Mog Liang Tuesday, August 24, 2010 2:26 AM
    • Unmarked as answer by Mick N Tuesday, August 24, 2010 2:28 AM
    Thursday, August 19, 2010 7:17 AM
  • Thanks Steven.

    That looks interesting.

    GoDaddy aren't 4.0 yet, but I'll look into this in any case and advise what I find.

    Thursday, August 19, 2010 7:20 AM