Click here to Skip to main content
Click here to Skip to main content

Running ASP.NET websites on Apache 2.2

, 3 Jul 2010
Rate this:
Please Sign up or sign in to vote.
Running ASP.NET websites on Apache 2.2

Motivation

I was running a VPS hosting for a few years. The problem with it is lack of latest technologies I would like to play with. And of course - as we have the hosting mainly for fun, I would not pay a lot.

Originally the VPS was pre installed with .NET 2.0 Framework. During the years, I have upgraded it to .NET 3.5 but at the end I was almost out of free space and I was still missing upgraded SQL Server.
So I was thinking about how to solve it. At home, I had an old notebook with Windows XP Professional installed.
Unfortunately on Windows XP, multiple domains can't be hosted under built-in IIS server.
When I was testing the module, I found that there is a problem with support of multiple cookies set from ASP.NET application. Fortunately, there is also a patch available for it - but you must recompile the mod_aspdotnet module.

Prerequisites

System Setup

  • Windows XP SP2
  • Microsoft SQL Express 2005
  • Apache 2.2
  • Mail Enable SMTP server
  • 2 domains, 5 subdomains (ASP.NET 2.0 applications and MVC 1.0 applications)

Apache Installation

I installed Apache using its default settings with the only one exception - I enabled development components for installation. It was because I was recompiling mod_aspdotnet module.

Module Compilation

I recompiled the mod_aspdotnet because of a bug in support of multiple cookies. Here is the available patch for this bug, but in the mean time it wasn't integrated into the sources.

Installation is quite simple. In the root of the source tree is available a batch file () which will show you how to manually install the compiled binaries.

Apache Configuration

Apache configuration is very simple and straightforward - an example which allows multiple virtual servers and Microsoft MVC for ASP.NET follows (more information can be found on the module's home page):

LoadModule aspdotnet_module modules/mod_aspdotnet.so 
LoadModule rewrite_module modules/mod_rewrite.so

AddHandler asp.net asax ascx ashx asmx aspx axd \ 
           config cs csproj licx rem resources resx \ 
           soap vb vbproj vsdisco webinfo 

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>

NameVirtualHost *

<VirtualHost *> 
  ServerAdmin admin@domain.net
  DocumentRoot c:/webroot/domain.net/test
  ServerName test.domain.net
  ErrorLog "logs/test.domain.net-error.log
  AspNetMount / "C:/webroot/domain.net/test"
# folders which shouldn't be handled thru Asp.net
# (see SetHandler in Directory definition)
  <Location ~ "/(Content|Scripts)">
    SetHandler None
  </Location>
  <Directory "C:/webroot/domain.net/test">
    RewriteEngine On 
    RewriteBase /
# redirect to the default location
    RewriteRule ^$ /Default.aspx [R=301]
# handle all files in directory thru the Asp.Net
    SetHandler asp.net
    Options FollowSymlinks Indexes
    AspNet All
    Order allow,deny
    Allow from all
    DirectoryIndex Default.aspx
  </Directory>
</VirtualHost>

References

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

voloda2
Software Developer
Czech Republic Czech Republic
I'm software developer since 1996. I started with assembler on Intel 8051 CPUs, during years I was interested in C, C++, Sybase PowerBuilder, PHP, Sybase Anywhere Database, MSSQL server and multiplatform development.
 
Currently I'm developing in C++ and C# (this is my favorit and I spent some time with MCPD achievement). I'm also interested in design patterns.

Comments and Discussions

 
GeneralHello Pinmemberxiaoheibai12-Mar-11 3:26 
GeneralHi Voloda Pinmemberricemaster00010-Feb-11 17:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web02 | 2.8.140721.1 | Last Updated 3 Jul 2010
Article Copyright 2010 by voloda2
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid