Visual Studio 2017 MVC on GoDaddy

GoDaddy is a premier hosting environment who adhere strictly to security standards and have outstanding service. However, when hosting Microsoft with GoDaddy I encountered several road blocks during set up which prompted this basic walk-through. Microsoft Visual Studio 2017 offers a mechanism within the studio to publish its web applications call Web Deploy, however, on GoDaddy shared servers there are several caveats that need to be handled first.

Here is a four step guide that I used to deploy my web application to GoDaddy which allows me to host both a  .NET application on the same server as my PHP driven WordPress application.

Step 1 (FTP Setup):

Setting up an FTP user is required for PHP projects, but not for the Microsoft Web Deploy tool.

 

 

 

 

 

 

Once you have set up an FTP user on GoDaddy using the images above as a guide to the steps used on the Plesk administration panel make sure to test it with a client like FileZilla by uploading a text file or downloading the current site for back up purposes.

Step 2 (Set up WordPress or GoDaddy Applications):

GoDaddy offers several applications that are not Microsoft based, but still quite handy. I chose to use their deployment of WordPress concurrently with my Microsoft project but I do not want to be overwhelmed with an enormous root directory. However, since the bin folder of any Microsoft Visual Studio project is expected to be in the root of it’s host and I did not want to deal with downstream complications associated with working around this limitation I chose to deploy my PHP application into a sub-directory. This has the added advantage of isolating code and media content which in turn will simplify version control and customization down the road of both of these projects.

Step 3 (Setting Up the .NET Hosting Environment on GoDaddy)

Not all .NET is equal and regardless of the fact that I will be using Git for local version control, being aware of the limitations and changes made to Microsoft framework versions is critical here. GoDaddy’s shared server hosting supports two frameworks (3.5 and 4.7). This means that my Visual Studio will be deploying .NET’s 4.6 Framework and my GoDaddy host will be configured to use the 4.7 .NET framework. This is because GoDaddy’s default of 3.5 is not compatible with 4.6. Again, although I could find ways to “trick the system.” As a general rule – I don’t. Why? Because GoDaddy and Microsoft have under their belt millions of customers – and I don’t. So, I do what they have independently decided is best practice for their products and have to use trial and error to perform gap analysis on these versions. In the end, this 4.6 to 4.7 version comparison was acceptable.

 

 

 

 

 

 

 

 

 

 

 

When I was done setting up .NET settings from the images above, I exported the settings so that I could import the profile into my instance of Visual Studio 2017.

Step 4 (Create your Visual Studio Project)

Notice that I’ve started with the server environment and afterward the Visual Studio project set up. That’s because this is the correct way to do it. In my experience as a developers I did not control hardware decisions, so to save time, money, several Advil not to mention hair I have waited to set up the .NET project for the last step.

Step 5 Remove the Roselyn Compiler

Now with all of this done, I am almost ready to proceed to customize both the .NET project with my own application while concurrently running my PHP application as an interface.However, there is one caveat that is not published anywhere on GoDaddy or Microsoft. This is a perfect example of a situation that developers will often encounter. So, what is it?

Simple. If all I did was create a new project and try to publish it to GoDaddy when I go to my url I will get the following error:


Cannot execute a program. The command being executed was \roslyn\csc.exe

Now, had I not already set my custom error mode to “Medium” or “Full” in step 3, then I would be getting the following error instead:


Error 500

So, it was important to be sure that the trust level be set to medium at least or full. This way IIS will display errors to the browser instead of failing to the log file or silently. However, in my case, my trust level is correct and so I got a long message which basically states that Roselyn is an executable that GoDaddy’s server does not trust to do what Microsoft has designed it to do in C# MVC projects. Rather than debate security practices with GoDaddy, the best solution is to remove Roselyn and fall back to the legacy compiler. To do this, go to the Tools menu of Microsoft Visual Studio and select “NuGet Package Manager” (the Microsoft equivalent of PHP Composer). Then select the “Manage NuGet Packages for Solution” and then locate the package named “DotNetCompilerPlatform” and remove it. After this I published the site and it worked just fine!

Credits for Additional Sources Go To:
  1. Ned from Port135 who found the work around to the compiler security limitation.
  2. Sourabh Somani from c-sharpcorner who put together a nicely done tutorial as a starting point
  3. Microsoft the source of Microsoft Visual Studio 2017 Community Edition
  4. GoDaddy for Excellent technical support to assist with troubleshooting error logs and local configuration requirements

 

3 thoughts on “Visual Studio 2017 MVC on GoDaddy”

  1. Hey there just wanted to give you a quick heads up.

    The text in your article seem to be running off the screen in Ie.
    I’m not sure if this is a formatting issue or something to do with web
    browser compatibility but I thought I’d post to let you know.
    The style and design look great though! Hope you get the issue fixed
    soon. Kudos http://keo365.com/the-thao

    1. After checking the article on a couple browsers, it seems to be a browser compatibility issue with the image alignments and divs. Will look into it and thank you for the feedback!

Leave a Reply

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