Deploying ASP.NET Application on IIS7 - asp.net-mvc

I am developing an ASP.NET MVC 4.5 application in C#. It works flawlessly when I run it after compiling on my local IIS Express.
However, when I try to upload it to a remote server it does not seem to recognize anything in its root directory. It only displays the default welcome screen.
I have tried reconfiguring the web.config file to point to Global.asax file, without any success. I am able to load single images by modifying the URL according to the sites structure.
What is the initial "starting file" on ASP.NET MVC 4.5 and how do I configure IIS7 to load it?

Check you server configuration (if possible), first enable Web Server (IIS) role (is posible to add from Server Manager or PowerShell), then install .NET Framework, or use aspnet_regiis.exe from .net framework folder (C:\Windows\Microsoft.NET\Framework\v4.0.30319 and C:\Windows\Microsoft.NET\Framework64\v4.0.30319) if server has configured iis web role and .net framework installed but configured incorrectly. If unsure what role features to add use Web PI and add IIS Recommended Configuration (http://www.microsoft.com/web/downloads/platform.aspx)
Note: In Visual Studio 2012 project template for MVC 4 Web Application references as copy-local MVC Assemblies from NuGet and therefor you don't need to install MVC 4 on web server.
Command to register current .NET version (from folder wich you are executing this utility, execute for both, first for 32-bit and than for 64-bit on 64-bit OS) with IIS:
aspnet_regiis -i
PowerShell to add Web Server role:
PS> Import-Module ServerManager
PS> Add-WindowsFeature Web-Server

If you see the default IIS welcome screen then it's probably because of incorrect website bindings (IP:port:hostheader). Whenever IIS cannot locate a website with specific binding it falls request back to "Default Web Site" with *:80 binding which you probably observe.

Related

HTTP Error 500.19 and error code : 0x80070021

I have a simple webAPI build by Visual Studio 2013. It works well when I run it from VS13 but when I copy the project in local IIS it gives me the following error.
HTTP Error 500.19 - Internal Server Error The requested page cannot be
accessed because the related configuration data for the page is
invalid.
Detailed Error Information:
Module IIS Web Core
Notification BeginRequest
Handler Not yet determined
Error Code 0x80070021
Config Error This configuration section cannot be used at this path. This happens when the section is locked at a parent level. Locking is either by default (overrideModeDefault="Deny"), or set explicitly by a location tag with overrideMode="Deny" or the legacy allowOverride="false".
Config File \?\C:\inetpub\wwwroot\APITeslin\web.config
Config Source:
36: <system.webServer>
37: <handlers>
38: <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
Got precisely the same error and came to this question. As #SpaceBison mentioned in comments, this answer describes the solution - https://stackoverflow.com/a/12867753/404099. I spotted it too late and it misses some steps. This is what worked for me:
Windows Server 2012, IIS 8.5. Should work for other versions too.
Go to server manager, click add roles and features
In the roles section choose: Web Server
Under Security sub-section choose everything (I excluded digest, IP restrictions and URL authorization as we don't use them)
Under Application Development choose .NET Extensibility 4.5, ASP.NET 4.5 and both ISAPI entries
In the features section choose: NET 3.5, .NET 4.5, ASP.NET 4.5
In the web server section choose: Web Server (all), Management Tools (IIS Management Console and Management Service), Windows Authentication - if you are using any of it
I got this error while trying to host a WCF service in an empty ASP.NET application. The whole solution was using .NET 4.5 platform, on IIS 8.5 running on Windows 8.1.
The gotcha was to
Open up "Turn Windows Features on or off"
Go to WCF section under ASP.NET 4.5 advanced services
Check HTTP Activation.
You'll be asked to restart the system.
This should Fix the HTTP 500.19!
EDIT 11-FEB-2016 Just got an issue on Windows 10 Pro, IIS 10, This time, it was an HTTP 404.0. The fix is still the same, turn on "HTTP Activation" under Windows Features -> .NET Framework 4.6 Advanced Services -> WCF Services -> HTTP Activation
I also was getting the same problem but after brain storming with IIS and google for many hours. I found out the solution.
This error is because some settings are disabled in IIS applicationHost.config.
Below are the steps to solution:
Go to C:\Windows\System32\inetsrv\config\applicationHost.config and open in notepad
Change the following key value present in
<section name="handlers" overrideModeDefault="Deny" /> change this value from "Deny" to "Allow"
<section name="modules" allowDefinition="MachineToApplication" overrideModeDefault="Deny" />
change this value from "Deny" to "Allow"
It worked for me.
If you're running IIS on that computer for the first time, you should try running the ASP.NET IIS registration tool (aspnet_regiis.exe).
Here's how to do that:
If you're using .net framework v4, open command prompt as an administrator, and change directory to your .net framework base folder using:
CD C:\Windows\Microsoft.NET\Framework\v4.0.30319
or, if you're using a 64 bit computer, use:
CD C:\Windows\Microsoft.NET\Framework64\v4.0.30319
when you've successfully navigated to the appropriate directory, execute the ASP.NET IIS registration tool using:
aspnet_regiis -i
If you're using a different .NET framework version, simply replace v4.0.30319 with the appropriate folder name.
Hope this helps.
I solved this by doing the following:
WebServer(ISS)->WebServer->Application Development
add .NET Extensibility 3.5
add .NET Extensibility 4.5
add ASP.NET 4.5
add ISAPI Extensions
add ISAPI Filters
On Windows 8.1, IIS 8.5 the solution for me was to register 4.5 from the control panel:
Programs and Features > Turn Windows features on or off > Information Information Services > World Wide Web Services > Application Development Features > Select ASP.NET 4.5
Click OK.
As the error idnicates - "This happens when the section is locked at a parent level". To unlock the section you can use appcmd.exe and execute the following command:
%windir%\system32\inetsrv\appcmd.exe unlock config -section:system.webServer/handlers -commitpath:apphost
For more information on about section locking and what a parent configuration context is refer to IIS documentation.
If it is windows 10 then open the powershell as admin and run the following command:
dism /online /enable-feature /all /featurename:IIS-ASPNET45
On Windows 8.1 or 10 include the .Net framework 4.5 or above as shown below
In our case, we struggled with this error for quite some days. It turns out that in control panel, programs, turn windows features on or off.
We selected Internet Information Services, world wide web services, Application development features and there we check the set of features associated with our development environment. For example: ASP.NET 4.6. .NET Extensibility 4.6, etc.
It works!
Try unlocking the relevant IIS (7.5) configuration settings at server level, as follows:
Open IIS Manager
Select the server in the Connections pane
Open Configuration Editor in the main pane
In the Sections drop down, select the section to unlock, e.g. system.webServer > defaultPath
Click Unlock Attribute in the right pane
Repeat for any other settings which you need to unlock
Restart IIS (optional) - Select the server in the Conncetions pane, click Restart in the Actions pane
In my case, there were rules for IIS URL Rewrite module but I didn't have that module installed. You should check your web.config if there are any modules included but not installed.
Your web.config describes that you're using forms authentication - make sure you enable forms authentication and disable anonymous authentication in IIS under the Authentication menu, for the website that is running in IIS.
I got Error Code 0x80070021 when migration IIS7 to IIS 10 in win 2016 box . .
Below steps helped me to fix it .
source
manually change value from "Deny" to "Allow" for below settings in
%windir%\system32\inetsrv\config\ applicationHost.config
under section:system.webServer
<section name="handlers" overrideModeDefault="Deny" />
Please <staticContent /> line and erased it from the web.config.
Well, we're using Amazon Web Services and so we are looking to use scripts and programs to get through this problem. So I have been on the hunt for a command line tool. So first I tried the trick of running
c:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -i
but because I'm running a cloud based Windows Server 2012 it complained
This option is not supported on this version of the operating system. Administrators should instead install/uninstall ASP.NET 4.5 with IIS8 using the "Turn Windows Features On/Off" dialog, the Server Manager management tool, or the dism.exe command line tool. For more details please see http://go.microsoft.com/fwlink/?LinkID=216771.
and I Googled and found the official Microsoft Support Page KB2736284. So there is a command line tool dism.exe. So I tried the following
dism /online /enable-feature /featurename:IIS-ASPNET45
but it complained and gave a list of featurenames to try, so I tried them one by one and I tested my WebAPI webpage after each and it worked after the bottom one in the list.
dism /online /enable-feature /featurename:IIS-ApplicationDevelopment
dism /online /enable-feature /featurename:IIS-ISAPIFilter
dism /online /enable-feature /featurename:IIS-ISAPIExtensions
dism /online /enable-feature /featurename:IIS-NetFxExtensibility45
And so now I can browse to my WebAPI site and see the API information. That should help a few people. [However, I am not out of the woods totally myself yet and I cannot reach the website from outside the box. Still working on it.]
Also, I did some earlier steps following other people responses. I can confirm that the following Feature Delegation needs to be change (though I'd like to find a command line tool for these).
In Feature delegation
Change
'Handler Mappings' from Read Only to Read/Write
Change
'Modules' from Read Only to Read/Write
Change
'SSL Settings' from Read Only to Read/Write
Check if IIS server installed the URL rewrite feature.
If it is not installed then make sure your web.config file don't have the URL rewrite related configuration
<!-- Make sure don't have below config, if server have not installed url rewrite feature. -->
<rewrite>
<rules>
<rule name="Fail bad requests">
<match url=".*"/> ...
Some time we copied the config from legacy server and straight away deploy to brand new server, then we may encounter such kind of 500 issue.
Had this today on a Windows 2016 Core server I resolved the issue by ensuring the components were installed as mentioned by GIOESCOM and then I repaired the SDK's in my case for .NET Core 3.1, .NET 5 and .NET 6 which resolved the issue and the ASP.NET 4.7.2 MVC web app worked.
This configuration section cannot be used at this path. This happens when the section is locked at a parent level. Locking is either by default (overrideModeDefault=”Deny”)
Hello guys
From older IIS and server
We may encounter the following error when we want to run our application on IIS 10 built on the new Microsoft Windows Server 2016.
HTTP Error 500.19 – Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
This configuration section cannot be used at this path. This happens when the section is locked at a parent level. Locking is either by default (overrideModeDefault=”Deny”), or set explicitly by a location tag with overrideMode=”Deny” or the legacy allowOverride=”false
The solution is very simple.
Follow the C:\Windows\System32\inetsrv\config file path from your computer. Change the overrideModeDefault=”Deny” part in the applicationHost config file to “Allow”. Then when you restart IIS, the problem will be fixed.
It works and save my time. Try it HTTP Error 500.19 – Internal Server Error – 0x80070021 (IIS 8.5)
The solution that worked for me was to delete my current Web.config and add a new one. That solved the problem for me

MVC4 WebSite 404 Error on IIS7

Set-up
I have a website built in Visual Studio 2012 using MVC 4 and .NET framework 4.5.
It is being hosted on a Windows 2008 and running IIS7.
I am using a VS2012 "Web Deploy Package" to deploy to the server. I manually copy this to the server and run the install using the web deploy cmd script option /T and then /Y. It all installs fine to the Test folder.
On the Test website in IIS the application pool is pointing to the DefaultAppPool which is set for integrated and pointing to the .Net Framework v4.0.30319
I have created a new Web Site in IIS for the application called Test and defaulted the bindings for port 80 and stopped the default web site that is in IIS.
I've created a new foldeer called Test under wwwroot which is where the Web Deploy script is set to point to, when I created the script I add "Test" as the Site/Application
When I have created the web deploy package on my local machine I am manually copying the zip file and other deploy files (cmd,*.xml) to the remote server
I have run %windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -i on the server and installed .net 4.5 framework and MVC framework components I could see in the Web Platform installer.
Problem
This website was previously being hosted on Windows Azure and have been able to direct publish to Azure and everything runs fine and when I go to any page it displays as expected.But on the new web server I get a 404 when I go to any page.
Everything seems to be installed as far as I can see on the web server. I was able to stop my website and re-start the default web site and add an index.htm file and that displays fine.
It almost seems like something in the MVC pipeline is not initialising. I'm using the standard Home controller with Index action that comes as part of the VS20102 MVC template as a test and that returns me a 404 when I go to /Home.
I've also tried other endpoints (I have WEB api rest endpoints off /API/* and these are returning 404 errors).
I'm just wondering if there is some basic set-up I've missed. It almost seems like some service is not running correctly and picking up the MVC website.

Can't make WebAPI application work on windows 2008 server

I'm new to Web API Applications. I created my very first application with only one simple Controller with only one Get() method that returns a List.
In my PC it works fine. Even after I publish the solution and access it via my IIS 7.5, the results are ok: I access
http://localhost/Application/api/Controller
and I get the answer I expect.
So I moved forward to the next step: deploying it to another server so other people in my office can access it. The server we use runs a Windows 2008 server. What I did was to simply copy the Publish folder generated by the publish command in Visual Studio 2012, and paste it in the inetpub\wwwroot folder in the server computer. Then, I accessed the IIS 7.5 that's running on the server and created a new application using the .NET 4.0 Application Pool, using the Publish folder as its physical path (exact same steps I did in my PC to publish it to my IIS).
The problem: when I try to access the application in the server machine (that's running windows 2008 server), I get the 404 error. It seems like it tries to find a physical path Application\api\Controller, insted of resolving it logically like my machine does.
I did try all the different solutions I found in the web:
I did enable all verbs in the ExtensionlessUrl-Integrated-4.0 under the mappings configuration for the Application in the IIS.
I did add the WebApiConfig.Register(GlobalConfiguration.Configuration); in my global asax.
What I noticed is that my machine has the .NET Framework 4.5 installed and the server machine only has the 4.0 framework (client and extended). But I get the same error even after compiling the application targetting the 4.0 framework.
The only MVC .dll I have in my bin directory is the System.Web.Mvc.dll... do I need any other DLL?
Thanks in advance.
Try this:
<system.webServer>
.....
<modules runAllManagedModulesForAllRequests="true" />
.....
</system.webServer>

ASP.NET MVC 3 Deployment 403 Error on Windows Server 2008 R2

I'm deploying an MVC3 application to a new server. The application runs fine on the development server (Visual Studio) and also under IIS7 on my development machine, but on the server I get a 403 error:
I have completed the following steps, but am now out of ideas. Please help!
Using the same xcopy deployment technique that I used on my development machine, I have deployed files to the to the server and added the following permissions to the folder:
IUSR - Read & execute, List folder contents, Read
IIS_IUSRS - Read & execute, List folder contents, Read
I have also installed ASP.NET MVC3 on server so additional required .dlls are in GAC
IIS is set up and I can access basic html files (such as test.html that I have dropped in at the site route).
I have checked in Server Manager that all Role Services are installed
Have attempted to bin deploy by copying files from MVC install location and putting in the bin directory
C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 3\Assemblies
C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies
Ok, found the problem. Here it is incase anyone else has the same issue:
The Server I'm using must have had .NET 4 installed before IIS. This meant that .NET 4 hadn't been registered with IIS.
I noticed the issue when checking IIS config. Clicking the .NET compilation icon for the website threw an exception, presumably because the application could not be compiled.
This led me to a stack overflow post that directed me to hanselman.com
In short, I had to install VS2010 on the server so I had the Visual Studio command prompt available, and then register .NET 4 with IIS on the command line.
IIS Manager can't configure .NET Compilation on .NET 4 Applications
http://www.hanselman.com/blog/ASPNET4BreakingChangesAndStuffToBeAwareOf.aspx
Key section:
"I installed ASP.NET 4 and then
installed IIS."
If you install VS2010 and/or .NET 4
first, then later install IIS, you
need make sure IIS is configured to
know about ASP.NET 4 otherwise IIS
will have no idea how to run ASP.NET 4
applications.
There's a simple workaround
If you are already in this state, drop
to the command line and navigate to
the FX install directory. Then run
"aspnet_regiis –iru".
Note if you are on a 64-bit machine,
run this command from the 64-bit FX
install directory – not the 32-bit
installation directory.
or for future reference, try to enable
IIS and the ASP.NET extensibility
option first when your are building
machines or VMs. That way when VS
2010 or .NET are subsequently
installed, the installation will
automatically detect the presence of
IIS and will auto-register with it.

Is it possible to test Asp.net MVC (being developed using Visual Studio) on Local IIS Web server as the root application of a website ...?

I want to test my asp.net MVC project (being developed using Visual Studio) on Local IIS Web server as the root application of a destinated website rather than as a nested/child application under the root application.
Note: Normally Visual Studio forces us to create Virtual Directory under the website if we test the project on Local IIS Web server.
Edit 1: Don't suggest me to publish it to the root application please because it is a bit tedious. I am sorry, I am lazy.
You don't have to create a virtual directory. Create a separate site in IIS (may be with a different port, for ex: 8080) and point that site to your local project web folder.
Now in visual studio set project url to http://localhost:8080, and you are good to test the site at the root.

Resources