Tip

How To Run ASP.NET on XAMPP

Due to the fact that the forums are now gone, I figured I should make a new tutorial on how to run ASP on XAMPP – especially since I can see many are still interested in this topic.

Step 1: Download & Install XAMPP

XAMPP Installer

I think you saw this coming: If you haven’t yet done so, you will need to download and install XAMPP.

XAMPP for Windows Installer can be downloaded here: http://www.apachefriends.org/en/xampp-windows.html.

Step 2: Download & Install mod_aspdotnet

Next you will need to download and install mod_aspdotnet, which will allow ASP.NET pages to be ran under XAMPP.

You can download the latest version of mod_aspdotnet here: http://sourceforge.net/project/platformdownload.php?group_id=175077.

When running the installer, it may take a few minutes before you can click “Next,” so be patient.

Once you can proceed you will be asked where you want to install mod_aspdotnet. The installer was able to automatically detect my Apache directory, but if it couldn’t – or if it didn’t select the one under XAMPP – use C:\xampp\apache assuming you did not change the installation directory in step #1.

Now sit back while the installer does its thing – which can also take awhile.

Step 3: Editing Configuration Files

Now you will need the help of Notepad (or my favorite, Notepad2) to open up the following configuration file: C:\xampp\htdocs\apache\conf\extra\httpd-xampp.conf

Once open, find <IfModule alias_module>, and place the following text between the aforementioned <IfModule> tag, but before the </IfModule> tag.

# ASP.NET on XAMPP
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 mod_aspdotnet.cpp>
AspNetMount /aspdocs “c:/xampp/aspdocs”
Alias /aspdocs “c:/xampp/aspdocs”
<Directory “c:/xampp/aspdocs”>
Options FollowSymlinks ExecCGI
Order allow,deny
Allow from all
DirectoryIndex index.htm index.aspx index.asp
</Directory>
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>
# /ASP.NET on XAMPP

Now save the file and create the C:\xampp\aspdocs directory (or whichever directory you used on the AspNetMount and other related configuration options).

Note: The font used on this website may convert the double quotes into curly quotes, so when copying and pasting this you will need to replace the curly quotes with the straight quotes — thanks to crdunst who pointed this out in the comments.

Step 4: Restart Apache

Finally, restart Apache via the XAMPP Control Panel (it may be hidden in the task bar in the notifications area) by stopping and then starting Apache.

Congratulations, you can now run ASP.NET pages on XAMPP!

However, you cannot run ASP.NET pages just anywhere. In order to view these types of pages (or at least actually run them) you will need to place them all in C:\xampp\aspdocs and point your browser to http://localhost/aspdocs.

Test Drive

If you want to make sure it is working as it should be, try out the following test page:

<%@ Page Language=”C#”%>
<html>
<head>
<title>ASP.NET Test Page</title>
</head>
<body>
<%
for(int fontSize = 1; fontSize < 7; fontSize++)
{
Response.Write(“<p style=\”font-size: ” + (fontSize * 10) + “pt; text-align: center;\”>It Works!</p>”);
}
%>
</body>
</html>

This should output seven “It Works!” messages, each bigger than the last.

Troubleshooting

I did receive comment pertaining to issues with this tutorial, which caused Apache to hang when trying to restart it – but I never had this issue.

Someone on the forums said in order to fix the hang issue you need to supply the direct path to the mod_aspdotnet.so file in the configuration edits I detailed above. In other words, replace modules/mod_aspdotnet.so with C:/xampp/apache/modules/mod_aspdotnet.so.

If you have any other problems, please leave a comment and I will try to help as best as I can!

I cannot take all the credit for this tutorial, you can find my original source here: How to make Apache run ASP.NET / ASP.NET 2.0.

You May Also Like:

  • http://www.sevenpixels.co.uk crdunst

    Thanks for the help with this, it’s exactly what I needed.  If it helps anyone else, the only snags I had were as follows:
    - if you copy and paste the text in the post to your httpd-xampp.conf file, ensure you change the curly double quotes from the post (such as around the path to the .so file) to regular straight quotes, otherwise apache chokes on them- create your /xampp/aspdocs/ directory before restarting apache, otherwise it gives an error when it doesn’t find the directory.Thanks again

    • http://www.todayinwindows.com/ Ian Aldrighetti

      Thanks! I updated the post with a note and gave you credit.

  • http://www.sevenpixels.co.uk crdunst

    Another thing I just found was that it worked OK after installing, but after restarting my machine I received a ‘The current identity (NT AUTHORITYSYSTEM) does not have write access to ‘C:WindowsMicrosoft.NETFrameworkv2.0.50727Temporary ASP.NET Files’ message.

    If you get this, just check the temp directory actually exists within the framework version directory. In my case it didn’t, but creating it manually did the job.

    • jcb

      If you do get the NT_AUTHORITYSYSTEM error you just to grant access to the version of the framework you are using:

      You can grant access to this account explicitly
      using the aspnet_regiis -ga switch, for example:

      C:WINDOWSMicrosoft.NETFrameworkv2.0.50215>aspnet_regiis -ga “NT
      AuthorityNetwork Service”

  • Freebie

    I can’t install mod_aspdotnet because it is showing like internal error 2908 and some other error. please reply alternative to my error

  • Steffen Winkler

    I just wasted twenty minutes because I forgot to replaces those pesky curly double quotes with straight double quotes in the .aspx file. doh!

  • Steffen Winkler

     you probably forgot to replace the curly double quotes with straight double quotes.

  • ClubFoot

    I changed the curlies to double quotes and I changed modules/mod_aspdotnet.so to the full path.  XAMPP still hangs when starting Apache.  Also, I could not locate the file ASP.NETClientFiles.  My Framework folder has six different version folders in it and none contain ASP.NETClientFiles.  :

    • ClubFoot

      One more thing: does this work on all versions of Windows?

    • http://profiles.google.com/ian.aldrighetti Ian Aldrighetti

      I would think it would work with whichever versions of Windows XAMPP and mod_aspdotnet supports.

    • http://profiles.google.com/ian.aldrighetti Ian Aldrighetti

      Interesting… You could try installing the latest version of ASP.NET, I believe there is usually an option to repair the installation, which could do it.

  • Nitish Alluri

    Its not working for me… maybe because i dont have aspdotnetclientfiles folder

  • Panagiotis

    Hi there,

    The service is starting without problem but I get an error:
    Access forbidden!

    If you can help that would be fine.

    Yours,

    PA

  • Abhinav Srivastava

    It gives me this error

    Diese Eingabeforderung nicht waehrend des Running beenden
    Bitte erst bei einem gewollten Shutdown schliessen
    Please close this command only for Shutdown
    Apache 2 is starting …
    Syntax error on line 88 of D:/xampp/apache/conf/extra/httpd-xampp.conf:
    AliasMatch takes two arguments, a regular expression and a filename

    Apache konnte nicht gestartet werden
    Apache could not be started
    Press any key to continue . . .

    • http://www.todayinwindows.com/ Ian Aldrighetti

      Could you please copy/paste line 88 of the httpd-xampp.conf file?