How to: One-Click Web publishing or Deploying your Website using Visual Studio

Web hosting Forums and discussions

Forums for Web hosting discussions: If you have any queries or questions related to web hosting services, place them here and get answered by our experts and customers. We invite you to even participate and provide solutions or answers that are known to any queries placed in this forums. We will get answer for all the queries and questions raised here.

How to: One-Click Web publishing or Deploying your Website using Visual Studio

0
In this Topic we will see how to deploy a Sample MVC Web Application using Visual Studio 2010 One-click publish feature: After you have created an ASP.NET Web application project or an ASP.NET Web site project in Visual Studio 2010, you typically deploy the project to a Web server for others to access your application. Deployment typically involves more than just copying the application's files from one server to another. You might also have to perform additional tasks, such as the following:


    Changing Web.config file settings that must be different in the destination environment, such as settings for debugging, or database connection strings. You could use File Manager to modify your web.config.

    Propagating data or data structures in databases that are used by the Web application. You would use SQL Management studio from your machine to connect to remote SQL DB server.

    Configuring Website IIS settings on the HostASP server, such as the application pool, the authentication method, whether directory browsing is allowed, and error handling. You will be using WebsitePanel control panel to perform this IIS settings.

    Installing security certificates. If you would need SSL you must take support from HostASP

    Setting values in the registry of the destination computer. - Is not allowed with HostASP Shared hosting

    Installing application assemblies in the global assembly cache (GAC) on the destination computer. - Is not allowed with HostASP Shared hosting


An extension to Microsoft Internet Information Services (IIS) that is named Web Deploy can automate most deployment tasks. Visual Studio provides tools that work with Web Deploy to make it easier for you to deploy a Web application project.

One-click publish - Web Application Project

Following steps will show you how to deploy a Web Application Project using One-click publish feature


    Creating MS SQL databases.
    Setting up Web publishing environment.
    Configuring your IIS Website application pool.
    Creating new Publish profile in Visual Studio.
    Setting up Publish Web in Visual Studio
    Setting up Publish SQL in Visual Studio
    Publishing your Website.



Step 1. Creating MS SQL databases. (WebsitePanel)
If your web application project uses MS SQL database then you would need to create a new database on your hosting account. To create new database follow the steps here. < Creating New databases > . You will use this information to rebuild publishing XML in the following step.

http://www.hostasp.net/articles/images/visual-studio-remote-deployment/vs-2010-ms-sql-server-db.PNG

Step 2. Setting up Web publishing environment. (WebsitePanel)
Login to your Web hosting panel and select your Website, you would see Web Publish properties Tab, now enabling this will create a new web publishing account. After your account is created you will see a link to rebuild publishing XML- click on the link and configure your database for use. Now after reconfigure is done, you will be able to download the updated Publishing XML for your Reference. This XML contains your Service URL, SQL server name, and other related information for you Visual studio publishing. (If you're using WebMatrix you could use this XML to directly import to WebMatrix IDE). (Download your publishing XML to your client machine)

http://www.hostasp.net/articles/images/visual-studio-remote-deployment/dotnet-webpublishing-settings.PNG

Step 3. Configuring your IIS Website application pool. (WebsitePanel)
This is a vital part you would need to really look into it and set it up correctly. You would choose appropriate Application pool depending upon your web application targeted framework, if you have app built on framework .NET 4.0 then your choice here would be 4.0. Please note that for MVC application you would need to select Integrated Pipeline. for rest of app you would select Classic pool which are just displayed as 2.0 / 4.0. Still the version depends on your targeted framework.

http://www.hostasp.net/articles/images/visual-studio-remote-deployment/dotnet-application-pool-settings.PNG

Step 4. Creating new Publish profile in Visual Studio. (Visual Studio 2010)
Now that we have configured our Web publishing setup on our hosting space. Let see how to setup Visual studio for Web deploy.
http://www.hostasp.net/articles/images/visual-studio-remote-deployment/vs-2010-create-web-publish-profile-menu.PNG
Open your Web project using Visual studio 2010, on menu bar you would see Publish: menu item. You could create as many profiles you want using this, let us see how to create a new profile now. Click on new profile option. This will launch profile screen as shown below. Open your Publishing XML and have it ready reference.

http://www.hostasp.net/articles/images/visual-studio-remote-deployment/vs-2010-publishing-profilesetup.PNG

a) Name your profile
b) Select publishing method as "Web Deploy"
c) Find publishUrl attribute in downloaded XML file and copy its value to Service URL field. (suffix with msdeploy.axd - refer figure above)
d) On Site/application field type your domain name (or) copy msdeploySite attribute value from XML file.
e) Leave untrusted certificate field checked.
f) Configure user name and password that your created in Web publishing tab on your hosting space
( you could refer userName and userPWD attribute from your downloaded publishing XML).

Click on Save button to save your profile. (See top right corner of the profile window)
Ok, we just saw how we will have to setup the publish profile. The next 2 steps 5 & 6 will be about how you want to make this publish process work for your website contents and MS SQL db.

http://www.hostasp.net/articles/images/visual-studio-remote-deployment/vs-2010-publishing-menu.PNG

Step 5. Setting up Publish Web in Visual Studio
Here in this screen you would determine what contents are to be deployed on your remote website. We will NOT concentrate on Packing-part instead we’re going to deploy directly to your hosting space. As you see on the image, you can determine whether only runtime components is required ( advisable for release version / production environment) (or) all files of your project and then you can also choose whether to exclude app_data folder and so on. Do not forget to “check” Include all databases configured in Package / Publish SQL tab if you’re using SQL server database for your web application project.

http://www.hostasp.net/articles/images/visual-studio-remote-deployment/vs-2010-publish-web.PNG

Step 6. Setting up Publish SQL in Visual Studio
You will be using this Publish SQL screen for setting up DB configuration. As you see in this screen, you will select the databases entries you want publish, you could also import directly from your web.config. Then you will need to configure your remote database connectivity for publishing your SQL and data. Refer to your downloaded Publish XML content for destination SQL server name, your database and its credentials. The connection string as you see on the image will be generated, after successful configuration of destination database setup. (You could copy this connection string and update your Web.config HostASP on hosting space.) Further down in this screen you could see scripting options that determine what to publish to remote DB (Schema / Data / both).

http://www.hostasp.net/articles/images/visual-studio-remote-deployment/vs-2010-publish-SQL.PNG

To setup HostASP remote database connection string, click on "..." button on Destination Database Information. This will launch configuration setup for remote database as shown below. You would refer to downloaded Publish XML to configure this part.

http://www.hostasp.net/articles/images/visual-studio-remote-deployment/vs-2010-database-connectionstring.PNG

Step 7. Publishing your Website.
Hurray, you're done with required setup for publishing your Web project. Now it is time to publish your website. On your Visual Studio menu bar select your publishing profile and click on “Publish web” (or) alternatively you could right click on your project name and select “Publish” action. This will copy all your web project contents, SQL database information as per configured setup in Visual studio.

http://www.hostasp.net/articles/images/visual-studio-remote-deployment/vs-2010-publishing.PNG

After you get your web project successfully published, you would need to update your connection string in web.config on your hosting space. You could see the connection string that you need in Step 6. above. This will make your Website point to your HostASP database.

You can now launch your sample MVC website that you just published.

http://www.hostasp.net/articles/images/visual-studio-remote-deployment/vs-2010-mvc-application.PNG

Good luck, if you have any queries contact HostASP support.
Technical specialist HostASP
Your Response
Please login first in order for you to submit comments