How to make ASP.NET MVC work in IIS 6? - asp.net-mvc

I have installed .NET Framework 3.5 SP1 and ASP.NET MVC CTP in a Windows Server 2003 R2 box, but my ASP.NET MVC site still doesn't work on that server. I was searching the internet and IIS for a solution and I noted that I can't choose other .NET Framework version besides 2.0 for my virtual directories. I'm almost sure if I correct this I can make my site work there.
Currently the main "/" URL answers with:
Directory Listing Denied
This Virtual Directory does not allow contents to be listed.
And the "/Default.aspx" URL answers with:
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: Section or group name 'system.web.extensions' is already defined.

Phil Haack has a pretty good writeup here
http://haacked.com/archive/2008/11/26/asp.net-mvc-on-iis-6-walkthrough.aspx

I had the similar issue.
I recently upgraded my server to support .net framework 4.0.
Converted my application to support .net fx 4.0.
Deployed the application on sever and trying to test .. I get "HTTP Error 404 - File or directory not found"
Solution
Open IIS Manager, expand the master server node (i.e, the Servername node), and then select the Web service extensions node.
In the right pane of IIS Manager, right-click the extension "ASP.NET v4.0.*".
Click the Allow button.

Besides Jason's answer, the common things to look for is:
Enable Wildcard mapping and point it to the aspnet assembly Phil mentions in Jason's link.
The /default.aspx error you are getting seems to be a web.config configuration error. At the very top of your web.config, look for:
<sectionGroup name="system.web.extensions"
Most likely it is defined twice. You only need the reference for the RC build you have. If you need the exact RC references, create a new ASP.NET MVC Web Project in a temp folder. And then grab the web.config from it.
-E

I also encountered this problem, in my case the solution was to uninstall the ASP.NET MVC Beta.
The application I was trying to get working had the version 1 MVC dlls bin deployed and once the Beta was uninstalled it all worked fine.

Similar issue: We tried to install an MVC4/.NET 4 app on an IIS6 box, set up everything as described, and got same error:
Directory Listing Denied
This Virtual Directory does not allow contents to be listed.
For us, the final fix was to add the UrlRoutingModule to the web.config:
<add name="UrlRoutingModule"
type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
Which makes sense, but I don't know why we needed to explicitly add it and others didn't. (We are running in a directory under Sharepoint, maybe related...)

Related

#Html.AntiForgeryToken Could not load file or assembly Microsoft.IdentityModel MVC5

It looks like a silly question but i have no way out to pass my error.
I'm working on ASP.NET MVC 5 and everything work fine on my local machine, even i deploy on my local IIS (IIS 7 on Windows 7)
I have a hosting (just a hosting, not a server) and now i deploy on that host and i get the message:
Could not load file or assembly 'Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. Access is denied.
The error line come from: #Html.AntiForgeryToken()
I have created a fresh mvc 5 project (not add any logic). I just add a simple form with AntiForgeryToken but the issue is still on my host.
So what the relating between Microsoft.IdentityModel and the anti forgery token logic of MVC 5 and does any way i can force MVC getting Microsoft.IdentityModel from my dll not GAC?
I really don't understand what's going on. Could anyone can help me the way to find out more clear and detail about my issue?
set "Copy local" to true in the reference properties for "Microsoft.IdentityModel" in visual studio and try again

.NET MVC deploy issue - "It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level"

I'm getting errors with a MVC web application which deployed to a host provider.
1) About the application
I had problems with deploying more complex applications also, but to make sure, I have created a simple application. Every info I will provide here will be about that simple application.
a) How did application created?
The application is a very simple .NET MVC Web Application created just for deploying test.
The application created with Visual Studio Express 2012 for Web, as ASP.NET MVC 4 Web application, and uses .NET Framework 4.
The application created on 'Basic' project template, then I added just one controller, and one view. That's all.
There's nothing else in the view than a header which says TESTING PAGE.
b) How did application deployed?
I used only FTP technique, with two tools.
I deployed the application manually with using FileZilla.
I get reference from an article about which files to upload. And also then confirmed the file list was matching with files uploaded with Visual Studio 2012, which I described below.
I deployed the application using Visual Studio 2012;
With using built-in Publish action,
Created new publish profile
Used FTP publish method,
No errors occurred. All succeed. And confirmed that directory has created and files has copied to server.
2) About the Host
Host I used is bought from an ordinary hosting provider.
It says it supports Asp / Asp.Net / Php5
There's nothing on my control panel except links to sections of: other packages hosting company provides, domains, my password and my personal info.
There's an ASP.NET website running on same host without any problem.
I'm trying to upload to a sub directory of an existing html website. e.g. www.example.com/theApplication
On the error I see, version information looks like this;
Version Information: Microsoft .NET Framework Version:4.0.30319;
ASP.NET Version:4.0.30319.272
3) About the Problem
When I browse the directory I have published the application to, I see an error message;
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.
(Error is on line 24)
Line 22: <customErrors mode="Off"/>
Line 23: <compilation debug="true" targetFramework="4.0" />
Line 24: <authentication mode="Forms">
Line 25: <forms loginUrl="~/Account/Login" timeout="2880" />
Line 26: </authentication>
And below that, error correctly points to root web.config file of the application.
And there's another 4 errors printed under 'Show Additional Configuration Errors:' title at the bottom, pointing to 4 different lines on the same web.config file. They are like this one;
It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS. (C:\webroot\site.com\wwwroot\test\web.config line XX)
Lines on the web.config file that errors points to;
(All inside xml tags)
profile defaultProvider="DefaultProfileProvider"
membership defaultProvider="DefaultMembershipProvider"
roleManager defaultProvider="DefaultRoleProvider"
sessionState mode="InProc" customProvider="DefaultSessionProvider"
4) What I have tried so far?
I'm an absolute beginner on .NET platform. So I cannot think of a possible cause or possible action.
Still, I have looked into many articles for two days, but cannot find anything useful. Google suffocates my searches with articles which all describes the solution of the same problem, but for hosting to local server. I could not found anything for this particular issue.
This is the problem:
I'm trying to upload to a sub directory of an existing html website
It sounds like you haven't setup this subdirectory as it's own application in IIS, which would cause you to see this error.

Getting MVC/cshtml/vbhtml pages working on IIS8

Been on this for hours...
New Windows 2012 server, fresh IIS 8 installation with all asp.net, 3.5, 4.5, ISAPI extensions/filters/whatever all installed.
Application pool is 4.0 and integrated mode. This is only website using that app pool.
Try and run website with index.vbhtml as default document (after adding it to default documents) and I get "cannot server this sort of page" "explicitly forbidden".
I look at "handler mappings" in IIS manager. .vbhtml is set to "forbiddenhandler" so I changed it to "System.Web.DefaultHttpHandler, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
Now I just get "The DefaultHttpHandler.BeginProcessRequest method is not supported by IIS integrated pipeline mode"
I'm now stuck! What's the problem with this darned server please?
IIS shouldn't directly serve those files, they are rederred through the MVC pipeline through a controller. If you have a file say, /Views/Home/Index.cshtml, you should be navigating to http://siteurl/home/index to see the content from that page via the Index action on your Home controller.
NOTE: Based on comment thread below, OP's underlying issue appears to have been with the installation (or lack of) ASP.NET MVC (or a corrupted installation, as he states in the comments that he did have it installed)

HTTP Error 403.14 - Forbidden The Web server is configured to not list the contents

I have downloaded the MVC Music Store ASP.NET application at location C:\Users\DEVESH\Desktop\Projects\MvcMusicStore-v3.0\MvcMusicStore-Completed\MvcMusicStore
and added the website on IIS at the same location. I have also given permission to IIS_IUSRS, but when I run localhost I am getting the error:
HTTP Error 403.14 - Forbidden The Web server is configured to not list the contents of this directory.
I have googled it, but have not found a fix. What I am doing wrong?
I came across this error because I had the wrong .NET version (v2.0 instead of v4.0) configured on the web site application pool. I fixed it this way on Windows Server 2008 R2 and IIS 7. I'm pretty sure the instructions apply to Windows Server 2012 and IIS 8 as well:
Press keys Windows+R to open the Run dialog, type inetmgr and then click OK. This opens the IIS Manager.
In the left treeview, locate the Sites node and find the Default Web Site node under it (or the name of the site where the error message appears).
Right-click the node and select Manage web site -> Advanced settings.... Note the name of the value Application pool. Close this dialog.
In the treeview to the left, locate and select the node Application pools.
In the list to the right, locate the Application pool with the same name as the one you noted in the web site settings. Right-click it and select Advanced settings...
Make sure that the .NET Framework version value is v4.0. Click OK.
This doesn't apply if you're running an older site that actually should have .NET v2.0, of course :)
In my case ASP.NET not registered on server. try to execute this in command prompt:
Windows 32bit
%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -ir
Windows 64bit
%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -ir
Just in case if anyone reached here looking for solution, here is how i resolved it. By mistake I deleted all files from my server ( bin directory ) but when i recopied all files i missed App_global.asax.dll and App_global.asax.compiled files. Because these files were missing IIS was giving me this error
403 - Forbidden: Access is denied.
As soon as i added these files, it started working perfectly fine.
I resolved this issue by correcting an error with my Global.asax file arrangement. I had copied across the files from another project and failed to embed the Global.asax.cs within the Global.asax file (both files previously existed at the same level).
In my case when I browsed to
site5.com
I got the following error.
HTTP Error 403.14 - Forbidden
The Web server is configured to not list the contents of this directory.
Most likely causes:
A default document is not configured for the requested URL, and directory browsing is not enabled on the server.
And then when I browsed to
site5.com/home/index
I was met with
HTTP Error 404.0 - Not Found
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
Most likely causes:
The directory or file specified does not exist on the Web server.
The URL contains a typographical error.
A custom filter or module, such as URLScan, restricts access to the file.
All that I did is installed the feature in IIS ASP.NET 4.8 as shown below.
I was using ASP.NET 4.5 MVC application on IIS 7. My fix was to set runallmanagedmodule to true.
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>
or If you have other modules, you may want to add them inside the module tag.
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<add name="ErrorLogWeb" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" />
...
</modules>
</system.webServer>
IIS Modules Overview : The Official Microsoft IIS Site
I have encountered similar myself before for 2 reasons;
1. MVC is not installed.
2. The url routing module is not registered (this varies by machine in my workplace for a reason I cannot fully explain - it is not always registered at a system level ), try registering it in the application web.config:
<system.web>
...
<httpModules>
...
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</httpModules>
</system.web>
Edit: I forgot to add the location for iis 7+:
<system.webServer>
<modules>
...
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</modules>
</system.webServer>
This error can happen when, in IIS Manager, the ASP.NET MVC site is pointed to the wrong directory.
In my case, I inadvertently had the site pointed to the solution directory instead of the child project directory. That is, I had the site's Physical path set to
C:\dev\MySolution
instead of
C:\dev\MySolution\MyProject.
Specific steps to fix this:
Open IIS Manager (Start > Run > inetmgr);
In IIS Manager, in the left pane, expand Sites;
Under Sites, left-click the ASP.NET MVC website;
In the right pane, click Basic Settings...;
In the Edit Site dialog, change the Physical path to the project directory.
Click OK.
This error occurs when the application cannot startup.
So the cause can be anything that prevents your application to start.
Wrong connection string
Wrong IIS directory permissions
An exception thrown in your Application_Start() function
IOC Container initialization error
IIS ASP.NET registration errors
Missing DLL in your bin folder
etc...
I faced a similar (but not identical) issue.
I had to go to to Turn Windows features on or off in Control Panel and add ASP.NET 3.5 and 4.7:
Then it worked for me.
I've just had the same problem, but my fix was that the Routing was not configured in the Global.asax.cs file. I'm using Bootstrapper and Castle Windsor, so to resolve this problem I added the following code to Global.asax.cs:
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
Bootstrapper.IncludingOnly.Assembly(Assembly.GetAssembly(typeof(WindsorRegistration)))
.With
.Windsor()
.With
.StartupTasks()
.Start();
}
}
Obviously if you are using the basic MVC then you will need to reference the RouteConfig file in the AppStart folder instead:
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
}
In my case, i had multiple projects but i had not defined the starting Project.
So this error was generating.
After defining the startUp project solved the issue.
I had this error after creating an empty ASP.Net application in Visual Studio. As soon as I added a file index.html to the main solution, it worked. So in my case, I just needed to add a file to the root of the project folder.
Check this also:
This problem occurs because the Web site does not have the Directory Browsing feature enabled, and the default document is not configured. To resolve this problem, use one of the following methods:
Method 1: Enable the Directory Browsing feature in IIS (Recommended)
Method 2: Add a default document Method
Method 3: Enable the Directory Browsing feature in IIS Express
LINK : https://support.microsoft.com/en-us/kb/942062
If project is a ASP.net MVC project it would be about routing.
In my case I changed default routing values:
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = "" }
);
I changed my code accidentally to:
routes.MapRoute(
"Default",
"{controller}/{action}/{JobID}",
new { controller = "Home", action = "Index", id = "" }
);
Thats I only changed "id" to "JobId" and default route can not be find.
In my case index.aspx file was not created by default and after adding another web form i did not set the form as start page ...After setting the page as start page my issue get resolved .
So right click a web form and set the form as start page
:)
IUSR permissions use on a folder if not under inetpub/wwwroot will be solution for some.
In my case, I had to disable 'Exclude files from the App_Data folder' in my publish profile to deploy the App_Data folder with my XML documentation (XmlDocument.xml). That got rid of the 403.14.
in my case:
1. in IIS Manager, in left tree, left click the computer name, in right dialog click ISAPI and CGT limitation, in open dialog, select ASP.NET v4.0.30319 and select enable. There is two ASP.Net v4.0, one for 32bit, another for 64 bit. select depending on your OS bit.
2. in left tree select app pool, in right dialog, select the app pool your website used. double click that pool, in open dialog, .net framke item select .net framework v.4.0.30319. and pipe..item select integate.
Maybe there is some wrong translation above because my OS is not English version.
In case anyone comes across this for a project other than MVC:
My project was a WCF project, which runs off .svc files--no default document. As a result I got a 403.14 error at myhost.com/ but as soon as I added a baseAddress path from my web.config file (ex. myhost.com/mybaseaddresspath.svc I got a webpage.
My colleagues made a URL Rewrite rule, which reduced all URLs to a StaticFileHandler; mapped to a file path at the root of my Application physical folder.
(i.e. an over-aggressive URL rewrite means that my Controllers/Actions were not working)
Check your applications' URL Rewrite rules to confirm they do what you expect.
I faced the same issue while developing Business Central application.
Open Business Central Application and Edit Web Client Base URL
under Client Services.
You can enter http://localhost:8080/YourWebServerInstance/
I faced similar issue. My controller name was documents. It manages uploaded documents. It was working fine and started showing this error after completion of code. The mistake I did is - Created a folder 'Documents' to save the uploaded files. So controller name and folder name were same - which made the issue.

Getting 404 error on MVC web-site

I have an IIS7.5 web-site, on Windows Server 2008, with an ASP.NET MVC2 web-site deployed to it. The website was built in Visual Studio 2008, targeting .NET 3.5, and IIS 5.1 has been successfully configured to run it as well, for local testing.
However, whenever I try and navigate to a page running in IIS7, I get a 404 error.
I have checked the following things:
There is no corresponding 404 log entry in IIS logs.
Actually, there are 404 entries in the IIS log.
The application pool for the web-site is set to use the Integrated pipeline.
The "customErrors" mode is set to off.
.NET 3.5 SP1 is installed
ASP.NET MVC 2 is installed
I've used MVC Diagnostics to confirm all MVC DLLs are being found.
ASP.NET is enabled in IIS, which we've demonstrated by running the MVC Diagnostics page.
KB 2023146 did highlight that HTTP Redirection was off, so we've turned it on, but no joy.
EDIT
Ok, so we've installed the world's simplest MVC application (the one which is created when you create a new MVC2 project in Visual Studio), and we are still getting 404s on any page we try and access - e.g.
<my_server>/Home/About will generate a 404.
Any ideas will be greatly appreciated!
This is quite often caused by the following missing from the web.config:
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
Do you have a problem with just 1 page or the whole site is not working?
A) 1 page
You can use RouteDebugger to verify if the route is matched correctly
B) Whole site
I assume you're using Windows Server - check if ASP.NET is enabled in IIS - it's disabled by default, I believe.
You can use MvcDiagnostics page to check if all dlls are deployed properly.
Are you running in IIS7 integrated mode? Classic mode of IIS7 does not automatically map extensionless URLs to ASP.NET (much like IIS6)
Make sure your Web.config tag is configured correctly.
We finally nailed this issue by exporting the IIS configuration of a working server, and comparing it to ours.
It was a really obscure setting which had been changed from the default.
IIS ROOT → request Filtering → Filename Extensions Tab → Edit Feature Settings → Allow unlisted file name extensions
This should be ticked.
This can be set at the IIS level, or the site-level.
Glad that fixed your problem. Others researching this issue should take note of the extensionless URL hotfix: http://support.microsoft.com/kb/980368
If none of the other solutions here solved your issue, check that you have the
Global.asax
file in your website. This solved the issue for me.
Checkout if KB 2023146 applies to your scenario. Also try requesting directly a controller action: /yoursitename/home/index
Apparently this can have many different causes.
For us, the problem was that the DNS entry was configured for two IP addresses, but the IIS configuration would only listen to one of them. So we got unpredictable results, sometimes it would work, sometimes a few files (css, etc) would not load, and sometimes the whole page would not load.
For me it was all about installing .NET Framework 4.6.1 on the server (my app was targeting that version)
You'll also get this if your bindings aren't correct. If you don't have www or a subdomain it'll return a 404.
I had this problem when running my MVC4 site with an app pool set to ASP.NET 4.0 and the Classic pipeline, even though the extension handlers were set in my web.config and were showing correctly in IIS. The site worked in Integrated Pipeline so I knew it was a configuration issue, but I couldn't nail it down. I finally found that ASP.NET 4 was disabled for the server in the ISAPI and CGI Restrictions settings. I enabled ASP.NET 4.0 and it worked.
In addition to checking if you're running in integrated pipeline mode, make sure your application pool is set to use .NET! I recently ran into this problem, and when I went in to check the app pool settings, I found that somehow it had been set to "No Managed Code." Whoops!
My Hosting company fixed this for me by doing this (I removed the original password value of course).
<system.webServer>
<security>
<authentication>
<anonymousAuthentication password="<password>" />
</authentication>
</security>
</system.webServer>
Typically I encounter this issue when there is a Routing problem. I compare a working vs non-working to resolve it.
Today however I accidentially created a Virtual Directory in IIS.
It has to be an Application, right click on the Virtual Directory (with a folder icon) -> Convert to Application:
Don't use runAllManagedModulesForAllRequests. You want to let IIS handle resources such as images.
<system.webServer> <!-- Rather do NOT use this -->
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
Instead add the MVC routing module
<system.webServer>
<modules>
<remove name="UrlRoutingModule-4.0" />
<add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" />
</modules>
</system.webServer>

Resources