ASP.NET on Apache

This is a quick and dirty HowTo ASP.NET on the popular Apache Webserver. It works with ASP.NET v1 and ASP.NET v2!

1) Download and install mod_AspDotNet

2) At the end of your httpd.conf file add the following lines: 
LoadModule aspdotnet_module "modules/" 

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

<IfModule mod_aspdotnet.cpp> 
  # Mount the ASP.NET /asp application 
  AspNetMount /SampleASP "c:/SampleASP" 
  #/SampleASP is the alias name for to execute 
  #"c:/SampleASP" is the actual execution of files/folders  in that location 

  # Map all requests for /asp to the application files 
  Alias /SampleASP "c:/SampleASP" 
  #maps /SampleASP request to "c:/SampleASP" 
  #now to get to the /SampleASP type http://localhost/SampleASP 
  #It'll redirect http://localhost/SampleASP to "c:/SampleASP"

  # Allow scripts to be executed in the /SampleASP example 
  <Directory "c:/SampleASP"> 
    Options FollowSymlinks ExecCGI 
    Order allow,deny 
    Allow from all 
    DirectoryIndex index.htm index.aspx 
   #default the index page to .htm and .aspx 

  # 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 

3) Continue with creating C:\AspNetTest.
4) Create a file “index.aspx” and add the following lines to it:

<%@ Page Language="C#" %> 
      <link rel="stylesheet"href="example.css"> 
           <% for (int i=0;i<5;i++= { %> 
              <font size="<%=I%>"> Sample ASP.NET TEST</font> <br> 
           <% } %> 

5) Restart Apache and visit http://localhost/AspNetTest – it should be working!

Hope that helps..


#1 Holmes on 07.14.06 at 11:50 am

A pretty nice HowTo.
Thats the comfortable part of Apache. Just editing one file. Works even with the current versions of Apache, although the developers have splitted the httpd.conf in seperated files – for what reasons ever.

So long

#2 Eric on 12.02.06 at 9:23 pm

It s working well, but not with codebehind 🙁
I tried with ASP.NET2

See u

#3 Petoj on 10.17.07 at 8:55 am

Link to mod_AspDotNet is broken for me :/ i just wanted to try it out but i got iis so i guess ill survive

#4 Ivan on 07.30.08 at 9:08 am

when i try to visit my SampleASP page i allways become this:

Server Error in ‘/SampleASP’ Application.

Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.

Details: To enable the details of this specific error message to be viewable on remote machines, please create a tag within a “web.config” configuration file located in the root directory of the current web application. This tag should then have its “mode” attribute set to “Off”.

Notes: The current error page you are seeing can be replaced by a custom error page by modifying the “defaultRedirect” attribute of the application’s configuration tag to point to a custom error page URL.

have any ideas ?

#5 nalin on 01.19.09 at 10:25 am

I could run My ASP.NET pages on apache Server
Thank You Very much

#6 RS on 05.15.10 at 4:40 pm


Thank you for this tutorial! I have ASP.NET run on Apache.

But I can’t find information about mod_aspdotnet Silverlight support.

Now when I’m opening my site in the browser I get an error with message “Could not load file or assembly ‘System.Web.Silverlight’ or one of its dependencies”.

Question: Is it possible to run Silverlight3 site with mod_aspdotnet?

If possible: what I must to do to make Apache find SL libraries?


Leave a Comment