MVC 3 Deployment to IIS6 - asp.net

Originally, I deployed the site with some of the DLL's set to copy local (as haacked suggested on another SO post). After this failed, I installed MVC 3 package on the server.
When I hit my site I get:
Directory Listing Denied This Virtual
Directory does not allow contents to
be listed.
I saw haacked's blog, but its almost 3 years old now and some of it just doesn't work anymore. Does anyone know what we need to do to get this to work after we installed MVC 3 on the server?
UPDATE
I found another link on haacked's blog. Apparently, this should just work (no need to do wildcard mappings). My website virtual directory is set to run ASP.NET 4.0.30319, I have installed ASP.NET MVC 3, and I am running IIS6 (windows server 2003 R2, Pretty sure that is IIS6).

The Virtual Directory was set to ASP.NET 4.0. While, the "Default Web Site" was set to run ASP.NET 2.0. I changed the "Default Web Site" to run 4.0 in addition to the virt. directory and it started working. The reason is a mystery to me, but it worked.

It sounds like you haven't set up the wildcard mapping. You need to configure a mapping in IIS that sends all requests to ASP.NET pipeline for processing. Since you don't have the mapping set up, it interprets the request as a directory browse (which is probably disallowed in your configuration).
From Haacked:
In the IIS properties for the website, click the Home Directory tab.
Click the "Configuration..." button. In the "Mappings" tab, click "Insert..."
Next to the "Wildcard application maps" label In the textbox, type in "c:\windows\microsoft.net\framework\v2.0.50727\aspnet_isapi.dll"
Uncheck the box labeled "Verify that file exists" Click OK

I believe ASP.NET 4 Extensionless URL feature is not working for virtual directory on iis v6 unless Default Web Site is also set to run ASP.NET v4.0.
For me, setting ASP.NET v4.0 to Default Web Site is not an option since it's breaking existing v2.0 virtual directory webapps.
Adding wildcard application maps on mvc3 virtual directory webapp worked for me.
Here's the list of steps that I did to deploy mvc onto iis6.
ASP.NET v4 is already installed on Windows 2003 server
Install AspNetMVC3Setup.exe
Copy the mvc3 webapp files onto server without mvc3 dlls in the bin folder
Create Virtual Directory pointing to the app folder
Set the ASP.NET version to 4.0.30319
Add Wildcard application map to c:\windows\microsoft.net\framework\v4.0.30319\aspnet_isapi.dll and uncheck the Verify that file exists

ABOUT WILCARD APPLICATION MAP: Be aware that this option causes IIS to intercept every request made against the web server. This includes requests for images, classic ASP pages, and HTML pages. Therefore, enabling a wildcard script map to ASP.NET does have performance implications.
OTHER SOLUTION: In W2K3 SP2 with IIS6, .NET Framework (2, 3.5, 4).
Goto Registry:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ASP.NET\4.0.30319.0
If is necesary create DWORD EnableExtensionlessUrls with value 0.
Then from command window execute: resetiis
Create a ASP.NET application from MVC3 Template.
Now in the global.asax setup the routes like theses:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
//routes.MapRoute(
// "Default", // Route name
// "{controller}.mvc/{action}/{id}", // URL with parameters
// new { controller = "Home", action = "Index", id = "" } // Parameter defaults
//);
routes.MapRoute(
"Default",
"{controller}.aspx/{action}/{id}",
new { action = "Index", id = "" }
);
routes.MapRoute(
"Root",
"",
new { controller = "Home", action = "About", id = "" }
);
}
Create AppPool for .NET Framework 4 and setup the web application to use this apppool. You can use the Denis Bauer's ASP.NET Version Switcher or use Aspnet_regiis.exe.
RESULT: the browser shows de About page as the default page.

Related

Recreation of Default Web Site on IIS 7

I've deleted by fault the Default Web Site into IIS 7. How do I please to add another one with ASP.NET 4.0 configuration.
I've tried to add a new website Default Web Site with ASP.NET 4.0 as pool and pointed it to C:\inetpub\wwwroot. But after creation, there is no asp.net folder under it. And when I've try to browse the web-app but I'm getting as error:
The path is not valid. Check the directory for the database. [ Path =
C:\inetpub\wwwroot\MyApp\App_Data\NAMESPACE.MyDataContext.sdf
]
Any brilliant idea, please?
You need to have default setting like following.
Also set bindings like following.

IIS ASP.NET MVC3 doesn't show my website

So I've set up IIS 7.5 to host my ASP.NET MVC website on my own local machine, but when I surf to http://localhost/ I just get this:
Welcome to ASP.NET MVC!
To learn more about ASP.NET MVC visit
http://asp.net/mvc.
A very basic HTML page with only this on it. No CSS or anything.
I haven't used IIS before, so I don't know what settings I need to change in order for this to work, but this is what I've done:
Added a new Site "MySite"
Set the Physical path to the root folder of my asp.net project
Tested the settings (everything OK)
Edited the "MySite" Application Pool and set it to .NET framework version v4.0.30319
What else do I need to do to make my website display? Thanks.
EDIT: please read this
I'll give a step-by-step walkthrough of what exactly I do:
1) I create a new ASP.NET MVC3 Razor web project. I don't do anyting but save and build the project.
2) I open IIS Manager
3) I go to Sites -> Add Web Site
4) I fill in following data:
Site Name: MyWebSite
Application Pool: MyWebSite
Physical Path: Visual Studio 2010\Projects\MyOwnProject\MyOwnProject (Project root folder)
Connect as: My PC's login and password. Test Settings is succesful
I leave the rest of the settings as it is and press OK
5) I go the Application Pools and edit the basic settings of MyWebSite to change the .NET framework to the latest version (v4.0.30319)
6) I select MyWebSite and click Browse *:80 (http) to go the web site. It opens up Chrome and I see the following page:
<h2>Welcome to ASP.NET MVC!</h2>
<p>
To learn more about ASP.NET MVC visit http://asp.net/mvc.
</p>
That's it. Nothing more. What am I missing here?
That looks like it is working (at least that's an MVC page it is displaying.) Maybe you need to alter your default route in Global.asax.cs to hit a different controller?
Do you have a Layout.cshtml in your shared folder and is your ViewStart pointing to it?
Edit:
I do remember having an issue like this at one point. I think it has to do with static resources pointing to the root which by default will be pointing to another App in IIS. I'm not sure if this is exactly the issue but what I do is setup an address in my host file for each application. For me the host file is :
C:\Windows\System32\drivers\etc\hosts
You have to run notepad or something as Administrator to edit it and add the following line:
127.0.0.1 MySite
This will allow you to simply navigate to http://mysite without any conflicts. Just double check your IIS setting so that the hostfile address point to the right physical path.
It seems I've fixed it, I don't know how or why this works. But this is what I've done:
In Visual Studio, I went to the Properties of my project. There, in the Web tab, I selected "Use local IIS Web Server", filled in "http://localhost/MyWebSite" and hit "Create Virtual Folder".
Save and build the project and suddenly it worked. However, I am not able to debug my project from Visual Studio now. But when I change the Web configuration back to "Use Visual Studio Development Server" it still works and I can debug again...
Doesn't make too much sense because you should be able to debug from IIS right?

Deploying ASP.NET 4 Web Forms Application Using Routing on IIS 6

To clarify, the scenarios I am looking at involve deploying ASP.NET 4 Web Forms application that employ RouteTable.Routes.MapPageRoute:
public class Global : System.Web.HttpApplication
{
public static void RegisterRoutes(RouteCollection routes)
{
RouteTable.Routes.MapPageRoute("questionnaires", "questionnaires", "~/Pages/Questionnaires/List.aspx", false);
RouteTable.Routes.MapPageRoute("questionnaires_submit", "questionnaires/submit", "~/Pages/Questionnaires/Insert.aspx", false);
}
void Application_Start(object sender, EventArgs e)
{
RegisterRoutes(RouteTable.Routes);
}
}
Scenario 1: The application is NOT hosted as a virtual directory in an existing website, but is a stand-alone website (it is its own starting point). It has its own application pool. When deployed, it worked without any tinkering.
Scenario 2: The application is hosted as a virtual directory underneath an existing website. It also has its own application pool. However, I received 404 errors when trying to access the routes I had mapped out. Fortunately, I had experience getting MVC to work in 3.5 sp 1, so I tried that method: opened the properties dialog of the virtual director, went to the "Directory" tab, click the "Configuration" button, and added a Wildcard application map to the aspnet_isapi.dll and unchecked the "Verify that file exists" checkbox. This made it work.
My question is why did I have to add a wildcard application map in the second scenario but not the first? If it helps, the root website that hosts the virtual directory in the second scenario is set up with ASP.NET version 2.0.50727.
ASP.NET 4.0 Enables Routing of Extensionless URLs
In ASP.NET v4.0, there is a better way to enable routing. Normally you're only interested in routing extensionless URLs, and have no need to route static requests (HTML, JPG, GIF, CSS, JS, etc). In v4.0 there is a new feature that allows extensionless URLs to be directed into managed code, without impacting static requests (HTML, JPG, GIF, CSS, JS, etc). Because of this feature, on IIS 6 you no longer need a wildcard mapping
See here for more info:
MSDN
Essentially, the .NET 4.0 routing dll is smarter than the 3.5 version. As a result, less work arounds. In your case, you probably have the standalone site running in full .NET 4.0 whereas in your virutal directory, the root is running under 2.0/3.0/3.5 mode. Hope this helps!

ASP.NET Routing (in WebForms) not working when deployed under IIS, works in IDE

I have an ASP.NET web application(webforms,not MVC) developed in VS 2008 and I have implemented ASP.NET web forms URL routing by following this link https://web.archive.org/web/20201205221404/https://www.4guysfromrolla.com/articles/051309-1.aspx#postadlink
It works pretty good when I run it on the Visual studion IDE.But does not works when I created a site under my IIS (IIS 5.1 in XP) and deployed the same files there. I have set ASP.NET version as 2.0 in the Properties window of my application too.But does not work. Any idea why? Is there anything else to be setup?
Try using the following content from "Using ASP.NET MVC with Different Versions of IIS" # http://www.asp.net/%28S%28ywiyuluxr3qb2dfva1z5lgeg%29%29/learn/mvc/tutorial-08-cs.aspx
Creating a Wildcard Script Map
If you don’t want to modify the URLs for your ASP.NET MVC application, and you have access to your web server, then you have an additional option. You can create a wildcard script map that maps all requests to the web server to the ASP.NET framework. That way, you can use the default ASP.NET MVC route table with IIS 7.0 (in classic mode) or IIS 6.0.
Be aware that this option causes IIS to intercept every request made against the web server. This includes requests for images, classic ASP pages, and HTML pages. Therefore, enabling a wildcard script map to ASP.NET does have performance implications.
Follow these steps to create a wildcard script map with IIS 6.0:
1. Right-click a website and select Properties
2. Select the Home Directory tab
3. Click the Configuration button
4. Select the Mappings tab
5. Click the Insert button (see Figure 4)
6. Paste the path to the aspnet_isapi.dll into the Executable field (you can copy this path from the script map for .aspx files)
7. Entery ".*" in the Extensions field
8. Uncheck the checkbox labeled Verify that file exists
9. Click the OK button
Check this System.Web.Routing RouteTable not working with IIS?
Are you trying to rewrite for a specific file extension, or are you trying to route all requests?
The reason I ask is because you may not have success with wildcard routing on IIS 5.1.
It works on IIS6 if you specify a wildcard map for the ASP.NET ISAPI filter.
Link with more info
IIS7 supports this via the integrated pipeline.

asp.net mvc: page can not found

I'm trying to setup the MVC development enviroment on my laptop. I'm running WinXP Pro with IIS 5.1
I got the environment setup with the sample MVC application that come with beta. I can only get to the home page. when i try to open About us page. i run into the page can not be found error. Is it the routing not set in the Global.asax?
Your issue is that IIS 5/6 don't play nice with routes without extensions, the home page is resolving because its pointing to default.aspx,
In a nutshell, do this:
If *.mvc extension is not registered to the hosting , it will give 404 exception. The working way of hosting MVC apps in that case is to modify global.asax routing caluse in the following way.
routes.Add(new Route("{controller}.mvc.aspx/{action}",
new MvcRouteHandler())
{ Defaults = new RouteValueDictionary (new{ controller = "YourController"} ) });
In this way all your controller request will end up in *.mvc.aspx, which is recognized by your hosting. And as the MVC dlls are copied into your local bin , no special setttings need to be done for it.
See this question for lots of good information:
ASP.NET MVC and IIS 5
You may go to your IIS site's properties, tab "Home directory", press "Configuration...", select ".aspx", press "Insert...", Type "c:\windows\microsoft.net\framework\v2.0.50727\aspnet_isapi.dll", uncheck check box and press "Ok". This heplped me.
Url rewriting can help you to solve the problem. I've implemented solution allowing to deploy MVC application at any IIS version even when virtual hosting is used.
http://www.codeproject.com/KB/aspnet/iis-aspnet-url-rewriting.aspx

Resources