Home .NET Migrating a site from Visual Studio 2012 to hosting. Parallels Plesk Panel

Migrating a site from Visual Studio 2012 to hosting. Parallels Plesk Panel

by admin

Hello!
There is enough written about ASP.NET MVC 3/4 site development. However, almost nothing is written about how to move it to a hosting / server. For me, as someone who came from linux hosts and PCB, the panel itself, folders, and compilation of the project – everything was new to me. There are manuals – if you torture yourself long enough, you can Google it. However, it turned out that the query "lay out the site, site transfer, deploy the site, create a site" almost no results. Or to scroll far enough. The correct query in this situation is "publish a site. However, there’s only Creating a Windows Azure Web Site and deploying an ASP.NET MVC 4 application there and Publishing ASP.NET MVC site to upgraded Windows Azure however this is by Azure.
Also, I faced the problem that there is no way to publish the site directly from Visual Studio 2012 to hosting – there is a proxy which does not allow to do this, although it allows to connect through FileZilla. I don’t know what the problem is. I went to the administrators – they said that the problem is in my Windows 8 Pro. Ok. It’s not that much of a problem.
And the control panel hosting itself. There are manuals, but in one place specifically on the beginning of work with it and the deployment of the site – not enough information. Especially for "newcomers" or PHPeshnikov, used to a little "other" logic of the process. And some of the information is in English. The programmer should not be surprised or confused by this. But every now and then.
I’ll start with the hosting. the panel looks like this :
Watch out for pictures!

Appearance of Parallels Plesk Panel

Migrating a site from Visual Studio 2012 to hosting. Parallels Plesk Panel
Migrating a site from Visual Studio 2012 to hosting. Parallels Plesk Panel
Migrating a site from Visual Studio 2012 to hosting. Parallels Plesk Panel
Migrating a site from Visual Studio 2012 to hosting. Parallels Plesk Panel
Migrating a site from Visual Studio 2012 to hosting. Parallels Plesk Panel
Migrating a site from Visual Studio 2012 to hosting. Parallels Plesk Panel

Creating a database. Changing the database connection settings.

First, we create a database. To do this, go to "Sites and Domains" – "Databases" – "Add a database". We choose what database to create. I have a choice between MySql and MsSql. We enter the name.
Migrating a site from Visual Studio 2012 to hosting. Parallels Plesk Panel
Go back to "Databases". Select the one you just created.
Migrating a site from Visual Studio 2012 to hosting. Parallels Plesk Panel
Select "Add user". Enter the required data.
Migrating a site from Visual Studio 2012 to hosting. Parallels Plesk Panel
That’s it. Remember all the data. Open Web.config and change the database connection string, where "Catalog" – database name, "User" – user name, "Password" – password, respectively.

<add name="DefaultConnection" connectionString="Data Source=.\MSSQLSERVER2008;Integrated Security=false;Initial Catalog=hedinco_zf2;User ID=dub;Password=1qaz2wsx" providerName="System.Data.SqlClient" />

Also, when transferring the project, I got an error because of the connection name, with the name "LocalSqlServer". Googled the solution. Add a connection string with that name. As a result, the connection section looks like this :

<connectionStrings> <add name="DefaultConnection" connectionString="Data Source=.\MSSQLSERVER2008;Integrated Security=false;Initial Catalog=hedinco_zf2;User ID=dub;Password=1qaz2wsx" providerName="System.Data.SqlClient" /> <remove name="LocalSqlServer" /> <add name="LocalSqlServer" connectionString="Data Source=.\MSSQLSERVER2008;Integrated Security=false;Initial Catalog=hedinco_zf2;User ID=dub;Password=1qaz2wsx" providerName="System.Data.SqlClient" /> </connectionStrings>

Add your own connection for DbContext if needed.

Additional settings before site compilation

We need to add in the same Web.config the line :

<system.web> <customErrors mode="Off"/> ....

You need to check that a number of dlls are copied into the bin folder during compilation.

  • System.Web.Helpers
  • System.Web.Mvc
  • System.Web.Razor
  • System.Web.WebPages
  • System.Web.WebPages.Deployment
  • System.Web.WebPages.Razor

To do this, in the Solution Explorer "References", find the desired libraries, and in the properties if necessary, change "Copy locally" from "False" to "True". Usually it’s set to True. But you should check it.
Also, I would like to note that there are problems with the output of the default page. Physically the addresses " hedin.com.ua " and " hedin.com.ua/home/index " refer to the same controller and method. But in the first case it threw me to " hedin.com.ua/cgi-sys/defaultwebpage.cgi " and gave an error

Server Error in '/' Application.The resource cannot be found.Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.Requested URL: /cgi-sys/defaultwebpage.cgi

I added a route to the RouteConfig.cs file for the empty address and everything was fine :

routes.MapRoute(name: "Root", url: "", defaults: new { controller = "Home", action = "Index" });

Site compilations and publications

Stop debugging, if it was started.
Select the desired project in the Solution Explorer, right-click and select "Publish…".
The first thing that appears is the profile. If not, select "Create" from the drop-down list.
The next tab – "Connection". Since there is no direct access on ftp – we choose "File System". Choose a folder where to copy the compiled site, ready for uploading to the server. You can also choose "FTP" and pour directly into the hosting. Then it will be necessary to specify the connection data.
Next. "Options. Select "Release/Debug". Check "Delete existing files". In order to always get an exact copy of the site, which worked for us in Visual Studio.
Click the "Publish" button in the lower right corner of the window.
And so. We have the necessary files, which we just need to copy to the server.

Copying a site to FTP hosting

Open FileZilla or other, convenient for you ftp client. Connect to the server. I have the following directory tree :
Migrating a site from Visual Studio 2012 to hosting. Parallels Plesk Panel
Go to the folder "httpdocs" (analogous to "www/public/public_html" on linux servers). And delete all the content (if hosting is new), or just update the necessary folders/files. Copy the contents of the directory where Visual Studio published the site to us.

Edit ASP.NET settings

In the admin panel "Sites and Domains", select the button "Show (hide) additional operations", "ASP.NET settings".
There will be a "Change Version" button. Choose the right one. By default, my version was 2. I chose version 4. Keep in mind that you need to create the project in Visual Studio with that netframework which supports hosting. I tried to create a 4.5 – it did not work. (Although, if, for example, create a site with 5.4 pp, and 5.3 on the hosting, but the project does not use "chips 5.4 "- the site will run fine.)
Click save.
That’s it. Go to your browser, and if your DNS is already updated and bound (hosting-domain), you will see your site working on the Internet.
I learned from a standard project created by VS.
If the domain is not yet linked to the hosting, or has not yet been bought, you can view using your hosting IP. To do this, in the admin panel, go to "Sites and domains". Scroll to the bottom. We see the name of our domain, and against the button. The first of these allows you to preview the site.
Migrating a site from Visual Studio 2012 to hosting. Parallels Plesk Panel
P.S. If you find any inaccuracies, errors, or have a way to make it better – I’ll be glad to know and if possible to correct it.

You may also like