Configuring ASP.NET MVC2 on Apache 2.2 using mod_aspdotnet
Trying to get an Microsoft MVC2 website to run on Apache 2.2 web server (running on Windows) that utilizes the mod_aspdotnet module. Have several ASP.NET Virtual Hosts running, trying to add another. MVC2 has NO default page (like the first version of MVC had e.g default.aspx). I have tried various changes to the config: commented out 'DirectoryIndex', changed it to '/'. Set 'ASPNET' to 'Virtual', will not load first page, always get: '403 Forbidden, You don't have permission to access / on this server.'
Below is from my http.conf:
LoadModule aspdotnet_module "modules/mod_aspdotnet.so"
AddHandler asp.net asax ascx ashx asmx aspx axd config cs csproj licx rem resources resx soap vb vbproj vsdisco webinfo
<IfModule aspdotnet_module>
# Mount the ASP.NET /asp application
#AspNetMount /MyWebSiteName "D:/ApacheNET/MyWebSiteName.com"
Alias /MyWebSiteName" D:/ApacheNET/MyWebSiteName.com"
<VirtualHost *:80>
DocumentRoot "D:/ApacheNET/MyWebSiteName.com"
ServerName www.MyWebSiteName.com
ServerAlias MyWebSiteName.com
AspNetMount / "D:/ApacheNET/MyWebSiteName.com"
# Other directives here
<Directory "D:/ApacheNET/MyWebSiteName.com">
Options FollowSymlinks ExecCGI
AspNet All
#AspNet Virtual Files Directory
Order allow,deny
Allow from all
DirectoryIndex default.aspx index.aspx index.html
#default the index page to .htm and .aspx
</Directory>
</VirtualHost>
# For all virtual ASP.NET webs, we need the aspnet_client files
# to serve the client-side helper scripts.
AliasMatch /aspnet_client/system_web/(\d+)_(\d+)_(\d+)_(\d+)/(.*) "C:/Windows /Microsoft.NET/Framework/v$1.$2.$3/ASP.NETClientFiles/$4"
<Directory "C:/Windows/Microsoft.NET/Framework/v*/ASP.NETClientFiles">
Options FollowSymlinks
Order allow,deny
Allow from all
</Directory>
</IfModule>
Has anyone successfully run Microsofts MVC2 (or the first version of MVC) on Apache with the mod_aspdotnet module? Thanks !
Enabling MVC apps on mod_aspdotnet is much easier than that. If you simply add
SetHandler asp.net
to your directory section in order to force all requests through the module. It behaves just like a wildcard mapping in IIS. Since this will process all requests, you'll want to make an exclusion for non-.Net content by adding a location section like this:
<Location ~ "^/MyWebSiteName/Content/.*"> SetHandler none </Location>
Where your Content directory contains all of your image files, css, etc. Alternatively you could write the rule to match a list of file extensions, but I find this easier. The added benefit to this is that you don't have to recode your apps. One other issue that you may encounter is with MVC2 you may not have a default.aspx placehoder to handle your root requests. To deal with use mod_rewrite and added:
RewriteEngine On
RewriteBase /MyWebSiteName/
RewriteRule ^$ Home [R=301]
to my directory configuration which forces redirects the / request to the Home controller.