Wednesday, July 8

Using Visual Studio to build a website, and publish it in the GoDaddy hosting site

I have a site fadshop.net hosted in the GoDaddy for several years. It is a Windows shared host, but only some static pages were stored, until today.

I planed to make a dynamic website, so today my first task is to use Visual Studio to create a "Hello World" application and publish it into this host. Although I have  10 years experience of using Visual Studio, starting from creating desktop application in Visual C++ 6.0, to creating a sophisticated .NET website using C# , plus 10 years experience of building website, starting from using notepad/frontpage to create static pages, to using ASP in Windows, php in Linux, python, setting up website in home computer, corporate servers, it still took me one whole day to complete this "Hello World" task.

The first question is "What kind of project in Visual Studio to create". Microsoft actually has a page "Choose between ASP.NET 4.x and ASP.NET Core". I finished reading it and thought the ASP.NET Core is the new, cool thing to follow. First mistake. After some long painful hours, including locating some Godday.com forum posts claiming 
.NET core 1.0/1.1/2.0 has now been installed on all of GoDaddy Plesk Shared hosting systems ... is available for use by default
I downgraded the .NET core package in my Visual Studio from 4.0 to 3.5 to 2.1 to 2.0, but the published application was still not working. Finally one post point me to the right direction:
In the Admin panel of website hosting, go to "Hosting Settings":
 
In this page, all the supported frameworks are listed:

The aforementioned .NET Core is not even listed, so my real choices are 4.8 version or 3.5 version of ASP.NET Framework. Now I can fire up Visual Studio to create an ASP.NET Framework 4.8 application.


The second problem is that I already have some static pages that shouldn't be disturbed by this new application, so I should either put it under one folder such as http://fadshop.net/dtalk or a subdomain such as http://dtalk.fadshop.net . The second option is better because it provides better control of the link in the application (I can use /slash to point to root ).  In the previous "Admin panel" screen shot, you can see the "Add Subdomain" button under "Websites and Domains". That will create a subdomain.


Now, in the Visual Studio publish step, you can choose either FTP or Web Deploy. In my experience, the two choices are both working fine, and I choose to use Web Deploy.


After it is published (today I published more than 10 times before everything is correct), visit the site (in my case, http://dtalk.fadshop.net), and I got  500 error message. The first thing is to change the Web.config ( I use FileZilla to retrieve the file into harddrive, then open it using notepad++. Or you can modify the Web.config in your VS project and do the publish again after modification) to add this line in configuration--system.web directive:

<customErrors mode="Off"/>
(Google gave me several different ways of writing this customErrors for different .NET application. This line is proven correct)
(There was one time that I added one space after "Off", before the /, then the site is not working. Changed it back, and the site is good. I didn't know Microsoft IIS is so sensitive to the space)
After uploading the modified web.config, I refreshed the site and got detail error information. With some more Googling and testing, One more line need to added (or modified, if it is already in the web.config file) to the same place:

<trust level="Full"/>
As in the following screenshot, the line 21 and the line 25 are newly inserted.

More information about the trust level can be found at MSDN . This is a link applied for old version of .NET Framework, but unfortunately due to the mess in Microsoft documentation, I am not able to find better resource.
Giving Full trust to an application doesn't sound like a good idea. But I tried other options, and none of them works. I don't like that, and I don't even know what "Full" means. So this trust level thing is totally useless: Microsoft wants to tighten the security, but because it is so difficult to use, everyone is abandoning the practice.

Also, it is required to comment out the "compilers" section in system.codedom:

(I have no idea why. Credit to a RandomUser in Godaddy Community)

After uploading this web.config, the website http://dtalk.fadshop.net is finally functioning to have the first "Hello World" page.

1 Comments:

At July 06, 2021 12:40 AM, Blogger Unknown said...

Visual Studio 2021 Crack This is a very helpful site for anyone, each and every man can easily operate this site and can get benefits.

 

<< Home