Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Hosting a WCF Service on GoDaddy

DZone's Guide to

Hosting a WCF Service on GoDaddy

· Web Dev Zone
Free Resource

Tips, tricks and tools for creating your own data-driven app, brought to you in partnership with Qlik.

For one of my projects, I need to use a WCF service to perform some data manipulations. It is targeting .NET Framework 3.5. It is all good when I try to test the service locally – either in the context of the ASP.NET development server or in the context of IIS7 – no problems at all with the default configuration.

image

The problem was quite unexpected – when I decided to host my service on my own space (paying for hosting with GoDaddy – Windows Server hosting [IIS7] with .NET support), it didn’t work. What I did is I created a simple folder using a FTP client called svc35 in the server root and copied the code-behind and the service files into that folder. When I tried accessing the service from the web browser, all I’ve got was this error message:

image

What I did first in this case is check the runtime version – I went to the hosting control panel and noticed that ASP.NET 2.0/3.0/3.5 was selected as the default option. Since I don’t know how the runtime is configured on the server, I switched this option to ASP 4.0 to eliminate the possibility of a framework version conflict (4.0 is backwards compatible anyway).

image

The problem persists. So what I did is I decided to cleanup the web.config file. By default, it contains lots of optional elements that I don’t need at first stages (after all, I can always add those later).

image

So what I did is I removed everything but what’s in system.servicemodel. The “clean” configuration file looks as simple as this:

image

But according to IIS, the problem isn’t yet solved:

image

This should be an easy fix – I opened web.config once again and simply added the snippet shown above to the main configuration. But there is another important point – as you can see the error is generated in the ‘/’ application – it represents the root node. So another error is expected even with customErrors set to off – the location is not correct and it is obvious that the service simply cannot find its core. To be specific, this is what should be expected:

image

In the IIS configuration manager (in the GoDaddy hosting control panel), I created a new virtual directory called svc35 (referencing my actual svc35 directory on the server) and set it to be the application root, that way all requests made inside the service will be relative to the application root, instead of the server root.

image

It will be pending setup for a while – it took around 10 minutes for my virtual directory to become ready.

image

Once it was ready, I tried opening the service again and encountered another error:

image

Notice that the application location changed, and now the proper assembly and code elements can be found. The error above is fixed by simply adding a base address prefix filter – basically, the fix is suggested by the error message.

image

Are we there yet? Not really – there is one more thing that should be handled – HTTP binding. For now, the service throws this error:

image

There is also an easy fix for this in web.config (add to system.servicemodel):

image

I found the part of the configuration file that defines my endpoint and set the binding configuration to unsecured (this is a name, not an attribute or mode) – the one I just created above.

image

I saved the configuration file and uploaded the new version to the server and there it is – a working service:

image

For now, I’ve noticed that these steps are needed to configure a 3.5 service – when I uploaded a 4.0 WCF service application, it worked right off the bat without additional web.config tuning.

NOTE: Don’t forget that the correct runtime version should be used.

Explore data-driven apps with less coding and query writing, brought to you in partnership with Qlik.

Topics:
dotnet ,microsoft ,tools ,platform ,service ,wcf ,net ,godaddy

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}