Deploy a MVC 3.0 web application project on IIS 8.0

15,335

I have found a complete solution to Deploying an MVC 3.0 Application using IIS8 on Windows Server 2012. Here are the Steps:

  1. Start your Visual Studio and select the "Run as Administrator" Option while running the IDE.

  2. Change your Web.config to add the following line of code .

    <globalization culture="en-US"/>
    

This ensures that even if your Target server has some different Settings, you enforce your own settings by mentioning this line of code. Otherwise , you might get problems such as -- Submitting a form which has a Date Field , you might not be able to submit as the Date will be set to

01/01/01 :00:00:00:00
  1. Build - Follow three sure-shot steps .

a. Clean Solution

b. Build Solution

c. Re-build Solution

  1. Check-in your solution completely if you are working on a shared Environment . Right click on the Project Solution and select the Publish Option. ( ScreenShot) enter image description here

  2. This opens up a Dialog Box such as this.(Screenshot 2) . This will show you possible options for deployment and some other settings.

On this screen you do not have to do much and pretty much it automatically sets the default settings for the current publish profile.

enter image description here

Next Screenshot :

Click on the next tab and you will see a bunch of options such as the following:

The first option asks you for the publish method . They are four options in this :

a. Web-deploy

b. Web -deploy package

c. File system

d. FTP

e. FPSE.

My Publish Method is "File System". I have also deployed applications using the Web- Dpeloy and the Web- Deploy Package, but for the sake of this article I will stick with File System.

The next parameter asks the Target Location where u want the Published folder to be. This can be a local Location on your Hard-Drive or a Remote location on the server. I have chosen a remote location on the server , there i have created a Publish folder and it is here where all my files will go after Publish.

The Destination URL is optional . I have left it Empty. enter image description here

Lets move on the next screen shot. enter image description here

The Settings tab gives u the following options :

  1. Configuration: There are two options in this drop Down - Debug and Release. Choose Release option.

  2. Make sure u tick the "Delete all existing files prior to publish" Option. This will clear all the existing files prior to every time u publish your project.

  3. This method of publishing does not support Database Publishing . Hence , if you are creating one in your project , then do not use this for publishing. In my case, I have used an external Database for binding to my Model Classes , hence this method will work.

In the next Screen Shot : You preview your settings before you publish the project. enter image description here

It will show the Target folder where the published Files/Folder will reside and the Project it is going to publish and again the warning stating that Databases will not be published .

Click on publish .

Check your Output Window as it will show Line by line the steps it will take for publishing.

In the end , it will display the message of Successfully Published Project .

Next step: Go to your location where your published files will be kept. ScreenShot: You should get something like this :

enter image description here

This is your published Folder and the Files . Lets now tweek the IIS to run web-site.

Go to IIS8 and right click the on this option as per the screenshot. ( This shot may vary from system to system ). enter image description here

Click on Add Web Site which opens up another Dialog such as below .

enter image description here

Enter Your Site Name and then Click on the "Select" Button on the right -hand side of the page, which will open up another Pop-Up as below.

enter image description here

Select your appropriate Framework from this Drop Down. Since mine is an MVC 3.0 Project , i went for ASP.NET 4.0 Settings. (Please try these options to know which settings suit you.)

Moving on, Enter/ browse to your physical Path where your solution is kept. In My case, the screenshot I showed where all my published files went . ( Sometimes to avoid conflict of folders , create a separate folder and enter that as your physical location and just copy the files from the folder where you published it to the new folder )

Leave rest of the entries as it is. If some application is already running on the Default -80 port , then give a new port . Click on OK.

Restart your IIS . Go to the browser and type out the URL .

And thats it !! Your MVC 3.0 Web Application has been successfully Deployed.

Thanks,

Mangesh

(PS -Please leave your comments for anything which is not clear and if you find it useful don forget to +1 :))

Share:
15,335
Mangesh Kaslikar
Author by

Mangesh Kaslikar

Hi all , My name is Mangesh Kaslikar. I am a software Engineer by profession and a big Programming enthusiast by all virtues . I have worked on ASP.NET 3.5, 4.5 , ASP.NET MVC ,WinForms Apps and Websites. I am currently studying at University at Buffalo. Other favorite languages and Frameworks - Python, R and HDFS- Map-Reduce Thanks

Updated on June 04, 2022

Comments

  • Mangesh Kaslikar
    Mangesh Kaslikar almost 2 years

    Normally, in webforms , when you have to deploy the application , we publish from the Visual Studio and put the published folder only on the server (IIS). But, in MVC web applications , how is it done.

    Does it follow the same way (published folder only on server ) or some other method.

    I have tried the following methods but not got any result .

    1. Web Deployment Package - After going through this tutorial -> http://pluralsight.com/training/players/PSODPlayer?author=scott-allen&name=mvc3-building-deploy&mode=live&clip=0&course=aspdotnet-mvc3-intro

    under the Web Deployment Packages tutorial ,i found how to create a web deployment package which can be imported in the IIS Management Tool. Then I found out this link to help me with the same ->

    http://www.iis.net/learn/publish/using-web-deploy/building-a-web-deploy-package-from-visual-studio-2010

    . But after following all the steps I got this error -> (See Screenshot) Error after Deployment What is/are the missing steps in this method?

    2. Add roles - Windows Server 2012 - turn certain features of ASP.NET 3.5 and ASP.NET 4.5 on. 
    

    I followed this tutorial for the above step ->

    http://www.iis.net/learn/get-started/whats-new-in-iis-8/iis-80-using-aspnet-35-and-aspnet-45

    As per the tutorial , I should for deploying a MVC 3.0 application , turn on the ASP.NET 3.5 and ASP.NET 4.5 features under the "Application Development" Tab . After this, to deploy the application ,i should under the "Advanced Settings" pop up choose .net V2.0 as the Application Pool ( See ScreenShot) enter image description here

    But even after following the tutorial i get the same error "Server error in Application ...."

      3. Publish under the "File System" Method. 
    

    We right-click the project and select "Publish" and a Dialog box pops up showing the various options for deployment. In this we select - " File System" ( See Screenshot) enter image description here

    We published the project , but got the same error once again.

    Problems / Questions ->

    1. What is the correct full proof way of deploying a MVC 3.0 application on IIS 8 . ?

    2. Do we need to put the whole solution on the server and run from there or otherwise

    3. Are we missing some step or some command in the above three methods

    4. Our requirement is to essentially find a way to put only the published folder on the server and run , but is that how it really works in MVC ( like web forms ) ?

    5. File System approach ( point 3 above ) is something which is done commonly for Webforms , is it advisable to do the same in MVC as well .

    6. The Deployment is working on localhost , but when tried by creating a Virtual Directory , it is again not working .

    Working environment is Visual Studio 2012 - Web Server Windows Server 2012- IIS 8

    Need help to solve the confusion.

    Regards, Mangesh

    • cheesemacfly
      cheesemacfly about 11 years
      Looks like you are doing it right (yes, you need to publish your website the same way you do it with webforms) but this link might help you resolve your problem: iis.net/learn/get-started/whats-new-in-iis-8/…