404 When Serving .cshtml in IIS 6 - asp.net

I'm trying to get an ASP.NET WebPages (Not MVC) site up and running with IIS 6, but I can't get it to serve .cshtml pages - It just spits back a 404 error every time. I've confirmed that it can serve .html and .aspx pages with no problem. So far, I've done the following:
Install ASP.NET 4.0 (aspnet_regiis -i)
Configure site to use ASP.NET 4.0 (aspnet_regiis -s ...)
Allow ASP.NET v4.0 Web Service Extension
Map aspnet_isapi.dll as handler for .cshtml files in Application Configuration (And as a wildcard mapping, no dice)
Add .cshtml to MIME types in Application Configuration
Ensure only ASP.NET 4.0 applications are in the app pool
Add <modules runAllManagedModulesForAllRequests="true" /> to web.config
Ensure that necessary .dll's are in the site's bin folder
Give "Everyone" group full control of the site folder and subfolders
I have a working site on the same framework that I set up a while back (And failed to document my process, lesson learned), so I tried exporting that site's config, creating a new site from file, and pointing it at the proper directory for the new site, but I'm still getting a 404.
I know that there are a whole lot of IIS/ASP.NET questions out there already, but every one I've seen is either not applicable to my situation (A lot of the MVC ones), or was solved by one or more of the things I've already tried.
Anyone have a clue as to what could be causing this?

CSHTML is templated page served by the Razor engine. Try opening an ASPX Page.
For serving cshtml, you need the Razor Engine configured.
Also, CSHTML are served differently based on the Routing configuration

Related

MVC 3 on IIS 7 returns 404 for MVC extensionless url requests

Our website is a mix of asp.net web-forms and MVC 3. The website is developed in web-forms, except for a separate MVC application that is stored in a separate Directory in the root of the website and having its own web.config. The web-forms pages (aspx) are served properly by the IIS 7 server, but MVC url's are returning 404 - File or directory not found.
For example, say the website is www.abc.com and the MVC application is accessed using www.abc.com/aaa/controller/action, where aaa is the root directory for the MVC application and contains its own web.config. The web-forms url (say www.abc.com/feedback.aspx) is working but, the MVC URL's (say (www.abc.com/aaa/Controller/Action) are returning 404.
I have confirmed from my shared hosting provider, that the website is running over .net 4 Integrated pipeline Mode application pool, so extensionless url's should be handled by the IsapiModule by default, without requiring any extra configuration for the same.
One doubt that crops in my mind is whether the MVC application root folder (aaa in above example) should be converted to a separate application ?
Any guesses, to resolve the above MVC url issue?
The hosting provider uses WebsitePanel , through which I was able to create a Virtual Directory for the folder containing the MVC application. The MVC URL's are now being routed to the Isapi handler and not returning 404(file not found) any more. So, I guess I will close this topic here.
In short, creating a virtual directory for the MVC application resolved the issue.
asp.net-mvc and webforms share the routing system. You should make a Hybrid WebApp, part WebForm and MVC. I did something similar recently here, where the webforms is the main app and the MVC is the nested one. In this case, you must have only one global.asax and a single web.config for the entire site. The MVC could live at the same directory as the WebForm, but only with they share stuff.
I followed this guide from Scott Hanselman to make this work.

IIS 6.0 web application - Does the entire "website" need to be an "application"?

I had a website hosted in IIS. One small section of it needed asp.net. So I just right-clicked that section/directory and made it an application and a virtual directory.
Is that alright? Or does the entire "website" need to be made into an application and virtual directory?
The reason I ask is that when I try to browse to the aspx page in this "application", I am getting a parser error message "Could not load type...MyCodeBehindType" in the page directive, which seems to me to indicate that it is not finding the dll's, or even the code behind class files (which are clearly in the same directory).
EDIT:
If I do it this way, with only a subfolder of my website actually being a web application, where do I put the dlls? In a bin folder of the website the web application is within? Or in a bin folder of the web application?
Making just a folder within a website, an application, should be fine. I usually have to remember to change the version of ASP.NET from 1.1 to 2.x, that may be what's causing the error.
In order to test the configuration, start with a blank test page (blank.aspx) with just HTML. If the HTML shows up, you know IIS is serving .NET pages.
If there is a problem with ASP.NET not being correctly registered for IIS, you could try re-registering it. Open the following folder:
%WindowsDir%\Microsoft.NET\Framework\x.x.x\
and run:
aspnet_regiis.exe -i

Url Routing is not working on IIS 6

Url Routing is not working on IIS 6. (using System.Web.Routing Namespace)
If i am running through VS 2008 then its working fine.
if i made virtual directory on IIS 6 then its not working.
its giving error 404 - file not found...
Thanks
By default, only files with extensions that are associated with ASP.NET (.aspx, .ashx etc) are sent to ASP.NET. You need to enable wildcard mapping to make sure that URLs to folders are processed (and thereby, routed) by ASP.NET:
http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/5c5ae5e0-f4f9-44b0-a743-f4c3a5ff68ec.mspx?mfr=true

overwriting a web.config root file to enable customerrors tag

I have a situation where I want to catch 404 errors fired by HTML pages (not just aspx pages) but I only have access to the web.config of the root folder of my website, and all sub directories (note, i don't have access to the actual IIS server and I cannot create applications or change settings)
So I did try the web.config customerrors on a subdirectory, and they do work, for ASPX pages only, not HTML pages, does anyone know why?
Note that the two answers above are correct for the usual case. However, IIS 6.0 and below can be configured to process HTML pages or anything else through ASP.NET. Also, IIS 7 has changed things radically - in effect, the ASP.NET pipeline is the IIS pipeline now, so that any piece of content is processed through any HttpModules.
Thus, in IIS 7 and above, anything you can configure for ASPX pages, you can configure for HTML pages.
You could have a look at the new routing capabilities for ASP.NET: http://msdn.microsoft.com/en-us/library/cc668201.aspx.
HTML pages are not parsed by IIS therefore are not affected by web.config settings. I am not aware of any way around this without configuring the settings in IIS.
To be a bit more specific than what Jeremy said, IIS maps different file extensions to different executables. By default it will be configured to let the .NET runtime handle .aspx files (in which case your web.config will be loaded & used), but it will serve the .html pages directly itself (& therefore fall back on its own 404 error handling).
Annoying, but I don't think there's much you can do beyond either having control of IIS, or by making your flat html pages into aspx pages (even though they contain no actual server-side content), to trick IIS into letting .NET handle them.

ASP file being caught by .NET isapi

I need to serve up a few .asp pages from within my ASP.NET site.
This ASP.NET site has a handler that allows us to serve up pages out of the database instead of finding them on disk (where the .asp files are located).
The problem appears to be that the .NET isapi (C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll) is catching my request... at that point, it is going to the database and not finding the file.
My question: why is ASP.NET catching my request? I would think it should come in and use the proper extension mapping for .asp (C:\WINDOWS\system32\inetsrv\asp.dll).
Is there a way to tell ASP.NET to leave the .asp files alone?
one alternative is to set up a virtual directory which only can execute .asp and without asp.net support.
It sounds like you have a wild card script mapping in your application configuration forwarding all requests into the aspnet_isapi.dll. Is the a .asp mapping to asp.dll?

Resources