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 .
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)
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)
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)
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
I have found a complete solution to Deploying an MVC 3.0 Application using IIS8 on Windows Server 2012. Here are the Steps:
Start your Visual Studio and select the "Run as Administrator" Option while running the IDE.
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
Build - Follow three sure-shot steps .
a. Clean Solution
b. Build Solution
c. Re-build Solution
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)
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.
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.
Lets move on the next screen shot.
The Settings tab gives u the following options :
Configuration: There are two options in this drop Down - Debug and Release. Choose Release option.
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.
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.
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 :
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 ).
Click on Add Web Site which opens up another Dialog such as below .
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.
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 :))
Related
I have an existing ASP.NET Webforms Application (see image below), and I've added a new WebAPI project. I have a few issues. The first is that according to various tutorials, it should just work, but alas...well, it does work when I right click on the project and Start New Instance in Debug mode. Right now, I have a single project set to start, but it doesn't activate the WebAPI project, and I would like it to. I know that I could set them both as startup projects, but then they end up in different browser windows, which is not what I want.
I would like to know how to get this second project to also start when starting the first, but in the overall solution sense. That way I can start my main site, but also hit the api/Donation url.
Right click on your Solution and select Project Dependencies.
Tick Donate for the shop.scramble.org project.
Run the Solution and you'll see in IIS Express both applications are running.
I have recently had to reinstall my development machine so I'm unsure how I did this before.
A solution which I have currently has 3 projects that are needed for startup for debugging, this works fine, when I run the solution I get 3 pages open up in the browser which makes logical sense, however on my previous installation of my machine I only had one page open up, the API and MVC projects didn't show in the browser, but they were running so the entire application worked.
Is there a way to suppress the unneeded pages from opening up in the browser?
I found the option after a while, it was in the project properties, not the solution properties!
Here are the details if anyone is interested:
Right-click on the Project
Choose Properties
Go to the Web tab
In the Start Action section select the 'Don't open a page.
Wait for a request from an external application.' option.
I've a problem with loading Web Application project in VS2013. This project depends on IIS Express, but I wouldn't install IIS Express because I already installed IIS.
What I can edit in .csproj file to load this project? I've tried to set to false, but it's wouldn't help me to solve problem.
Thank you for advice.
Upd.1: Also, I cannot create new web projects - VS tell me same things.
Happened to me too. My workaround:
Right-click the (failed-to-load) project => edit web.csproj
Find the line <UseIISExpress>true</UseIISExpress>, and change it to false.
Save, close, reload project.
Result - different error:
The Web Application Project web is configured to use IIS. To access local IIS Web sites, you must run Visual Studio in the context of an administrator account. In addition, you must install the following IIS components:
ASP.NET
So:
Edit again, change <UseIIS>True</UseIIS> to false
Save, close, reload project.
Result - Great Success!
Try to delete user config file "ProjectName.csproj.user" then reload project.
VS 2012 can't load project which uses IIS with custom binding host - thinks it's using IIS Express
It happened to me today. Changing "UseIIS" to false allowed to load project, but not use IIS. After some tests I've found the cause of the problem:
On previous CheckIn to VSS somehow the UAC (user account control) was switched on. So actually there were two alternatives: (i) Always use "Run as administrator" ; (ii) switch UAC off.
I prefer (ii).
I had a custom host file setup up with foo.localhost -> localhost bound on both ports for HTTP/HTTPS
checking on something i removed the host header for the binding on port 80.
once reloading solution is when everything started crashing.
found a really old post that reminded me that i removed that host name from the binding.
adding foo.localhost header back to the binding and all my projects started reloading.
If nothing works, try removing following two lines from .csproj file. (always worked for me)
<ProjectGuid>{3AA499DF-4A65-43B7-8965-D08A4C811834}</ProjectGuid>
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
Occasionally I have a problem when I attempt to update a web reference in Visual Studio 2008 (this also happened in VS2005). It has happened in several different solutions.
When I have a solution with a (.NET 2.0) web service and a project that references the web service I get "There was an error downloading 'http://localhost:3890/MyWebService.asmx' Unable to connect to the remote server.". Obviously, the port number in the example is an example only, it could be any port number.
The web reference is set to 'Dynamic URL' and the web service is using the ASP.NET Development Server web server rather than IIS. When the error occurs the icon for the service never shows up in the system tray.
I have found two workarounds. The more drastic workaround is to delete the web reference and recreate it. This has worked for me everytime, but has caused some confusion for Subversion and AnkhSVN.
Recently it occurred to me to set the web service as the startup project, start it, and mouse over the ASP.NET Development Server icon on the system tray to find out the port number that it has chosen. Then, edit the port number in the WebReferenceUrl property of the web reference. After doing this I can update the web reference.
While this works I feel that there must be a better way. It seems that VS and Cassini should be able to resolve this without manual intervention. Am I missing something, or is this another case of Microsoft getting the difficult things right and the simple basics wrong?
I have attempted to search an answer for this issue and have found several threads describing the problem. But, no one has identified a real solution.
Right-click the service in Solution Explorer, and choose "View in Browser". That will cause the service to start, and you'll be able to use "Add Web Reference".
You can force the port of the test web site in visual studio.
Open the properties window in visual studio it with "F4" or via the toolbar - "View" -> "Properties Window".
Left click on your web site in the "Solution Explorer" window. Notice the drop down list for the "Use dynamic ports" setting. If you set this to "False", you'll then be able to specify a fixed port in the "Port number" field.
Set this to your desired port value.
Launch your web site. You'll see the port used matches the value you specified.
Go to project Properties-> Settings -> [Update the Service Url]
It Works.
Check appconfig file and update the port number accordingly
I am creating a clickonce installer using the deployment strategy of Install from the Web or network share, on one of my project. I am learning how to use click once installers. When i publish my project it gets succeeded. i gave the URL of my website that i had created through google so that anyone can install from that URL. After publish gets succeeded the URL should be launched automatically but it is not. Moreover. When i check my website and in it that page whose URL i had given, there is nothing there. No installer. Please help.
Right Click on Publishing Project
Click Properties
Click "Publish"
In "Publishing Folder Location" is anything set there?
Click the button with ellipsis (...) to the right of the combobox
Click "FTP Site" (not Remote site, as this needs FrontPage extensions)
Enter the Server information, Directory (that you have access to), keep it as passive mode, uncheck the Anonymous option and put in the valid FTP instructions.
Click Open, and Republish. All should work 100% with this.
If not, have a look in your wwwroot/ folder and find the application information (if it's there) and you will have to manually upload the files.
EDIT for comment:
The website that you are uploading to, does it have FTP access? Meaning a place that you would upload file to for display on the website, even like your html content? (index.html etc.)
If not, you will need to get these details from your website hosting provider and fill in the appropriate fields for the FTP upload.
It's a while since I did this, but I'm fairly sure that you have to upload the files manually.
The installer needs the location so it can build the web page etc. All the files should be in an output folder in your project.
EDIT: I've just checked and the output folder is the one you specify on the first step of the Publish Wizard. If you specify a local folder the files will be put there for you to FTP to your website later. You can also specify a remote address as and FTP or HTTP location (which I'd forgotten when I posted my original answer). You'll have to enter the user name and password for connecting to the remote location later in the process.
Are you using Visual Studio 2008? The default behaviour of deploying a "publish.htm" page has changed.
Bring up your project's properties and switch to the "Publish" tab. Click the "Options" button and switch to the "Deployment" section of the dialog. You'll see by default that the "Deployment web page" TextBox is empty. You'll need to give that a value and also check the "Automatically generate deployment web page after every publish" CheckBox.
I've taken to filling that in with "default.htm" so that whichever folder you deploy your app into will have the ClickOnce publish page as its default page.