Suramya's Blog : Welcome to my crazy life…

June 24, 2007

Getting a 404 error in asp.net when the file exists on the server

Filed under: Computer Software,Computer Tips,Knowledgebase — Suramya @ 1:25 PM

Hit this issue recently on a web server that I was setting up on Windows 2003 server using IIS. Now everything was installed correctly and I had copied all the files to the server, then I created a virtual directory for my asp.net application and when I went to http://localhost/Test it would show me the directory listing (Yes I had enabled that so that I could debug). However when I clicked on the service.asmx file it would tell me that the file didn’t exist and I would get a 404 error. Now I knew that the file was there and I could see it in the directory listing but for some reason the IIS refused to show it.

The problem was caused because the server was running the 64 bit version of ASP.NET 2.0 while we were expecting the 32 bit version. Yes, it took me a couple of hours to figure that out. To fix it basically what you have to do is tell IIS that you want to use the 32 bit version for this particular Virtual Directory by changing the Script Map. The steps to change this are:

  • Open the IIS management console.
  • Expand the local computer node, expand Web Sites, and then expand Default Web Server.
  • Right-click the folder for the application, and then click Properties.
  • On the Directory tab, click Configuration.
  • The Application Configuration dialog box appears.
    On the Mappings tab, select an ASP.NET application extension, such as .asmx or .aspx.

    The Executable Path column of the dialog box lists the path to the ASP.NET ISAPI extension used by the application. By default, the ASP.NET ISAPI extension is installed in the following location:

    %system root%\Microsoft.NET\Framework\versionNumber. Browse to the appropriate directory and select the aspnet_isapi.dll file.

  • Click Ok and exit
  • Finally Stop and Start the webserver for the changes to take effect.

Now you should be able to access the files on the server without issues.

BTW, also make sure that the user IIS is running as also has permissions to read files and execute scripts in the directory where you have copied your files.

Hope fully you found this helpful.

Source for the steps to change the mapping: How to: Configure ASP.NET Applications for an ASP.NET Version

Thanks,
Suramya

3 Comments »

  1. Hi,
    Thanks for the hints, I had the similar problem, however, in my case I just forgot the fact that once installed, IIS 6 is in “locked down” mode which prohibits execution of all types of scripts, so all I had to do is to enable ASP.NET in IIS management console.
    Thanks anyway!

    Comment by Alexey — April 16, 2008 @ 12:02 AM

  2. Thanks for the tip. That solved a problem that I had

    Comment by Phil — December 9, 2009 @ 3:31 AM

  3. Thanks for the info… this was a great help as i had spend my entire day on this issue

    Comment by Kopi Tribulusdynamic — January 26, 2010 @ 5:19 PM

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress