Hosting ASP.NET on Shared Hosting Site

Within the last few weeks I decided to take the venture of moving my host provider from one web hosting company to another. At the same time I decided that I wanted to do Windows hosting going forward so that I could host ASP.NET applications. I figured this would be easier since I know more of C# and .NET than I do PHP and the linux web hosting technologies. Boy, was I wrong…

So the first issue was with the domains. Normally when you transfer domains from one provider to another it can take up to 7 days. For some reason one of my domains transferred in what felt like hours. Instead of a week I received the email that the domain transferred in a day or two. Although I received an email that the domain transferred and it showed on the new provider, the old provider also still displayed the domain. Thus when I deployed my new website and all the files to the new provider it would sometimes display the old provider. Awesome times…

Once that was straightened out my new site starting throwing a 403 – Forbidden error anytime that I browsed to the page. The 403 error seemed consistent but then when I deployed my solution would work and I could browse to the pages without issue for a few minutes until the 403 error would resurface. Contacting the host provider the 403 error appeared to be caused by settings on the server. This lead the provider to ask me to change several things in my web.config file as well. This included code to add the following:

<modules runAllManagedModulesForAllRequests="true"></modules>

This seemed like a bit of overkill. This also did not fix the issue either. Instead the error continued and given that this didn’t seem to work, I reviewed other solutions and suggestions made online and replaced the above with:

<remove name="UrlRoutingModule~4.0" />
<add name="UrlRoutingModule~4.0" type="System.Web.Routing.UrlRoutingModule" preCondition=""/>

Although this code seemed to directly address the issue, it didn’t work either.

The issue at this point was diagnosed to be with ASP.NET and more specifically the MVC routing within. None of the views were being properly executed and the controllers were never being reached. No matter what I did the error would not cease as every time I deployed it worked for a while and then around 30 minutes later it would go back to 403 – Forbidden.

The issue turned out to be an issue with the precompile setting on the publish settings dialog. Below is the settings dialog.

Visual Studio 2015 Publish Settings Dialog
Visual Studio 2015 Publish Settings Dialog

The second checkbox was causing the issue. For some reason checking this box would cause a security issue that would prevent the MVC Routing for executing properly.

Maybe next time I will realize the shortcut isn’t worth it…

Leave a Reply

Your email address will not be published. Required fields are marked *