Troubleshooting a 404

Since IIS 6, Microsoft has made it very easy to troubleshoot the cause of a 404 "not found" error from the web server.  Most admins don't realize that the IIS log file can now include the substatus code along with the 404.

The first step is to make sure that you are using the W3C log file format and that you have selected Protocol Substatus code as one of the extended logging fields as in the example below.

 

You can now lookup 404 entry in the log file to determine why the resouce is coming back as "not found".  In this example, we see a request for a Flash file that is failing:

#Fields: date time c-ip cs-username s-computername s-ip cs-method cs-uri-stem cs-uri-query sc-status sc-substatus sc-win32-status sc-bytes cs-bytes time-taken cs-version cs-host cs(User-Agent) cs(Cookie) cs(Referer)
2009-04-10 00:21:55 133.71.125.97 - WEBSERVER 133.73.246.56 GET /media/logic.swf - 404 3 0 93241 920 2141 HTTP/1.1 www.server.com Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1+.NET+CLR+2.0.50727;+MS-RTC+LM+8) - -

You can see that the status and substatus logged are 404 3.  The following MSKB articles are helpful for looking up the status codes with their corresponding causes and remedies:

IIS 6:  http://support.microsoft.com/kb/318380
IIS 7:  http://support.microsoft.com/kb/943891

The MSKB tells us that 404.3 means that the mime map policy prevents this request. In other words, the .swf file is an unknown mime-type to IIS. We simply need to define the mime-type for .swf and IIS will now serve the file.

The following articles are also helpful in torubleshooting 404 errors:

3 Comments

  • wonderful

  • We are experiencing a problem in uploading files to web server using the WEBCLIENT interface in Windopws 2008. Our application code was working perfectly when our IIS server was running in Windows 2003 but when we ported it to Windows 2008, it started throwing "(404) Not Found" exception. This happens on the "GetResponse()" method of webrequest. An excerpt from code is given below.

    // The WebRequest
    oWebrequest = (HttpWebRequest)WebRequest.Create(oUploadURL);
    oWebrequest.ContentType = "multipart/form-data; boundary=" + sBoundary;
    oWebrequest.Method = "PUT";

    // This is important, otherwise the whole file will be read to memory anyway...
    oWebrequest.AllowWriteStreamBuffering = false;

    // Get a FileStream and set the final properties of the WebRequest
    oFileStream = File.OpenRead(vsLocalPath);
    iLength = oFileStream.Length;
    oWebrequest.ContentLength = iLength;
    oWebrequest.KeepAlive = false;
    oWebrequest.Timeout = 4 * 60 * 60 * 1000; //4 hours; //20 * 60 * 1000
    oRequestStream = oWebrequest.GetRequestStream();

    // Stream the file contents in small pieces (4096 bytes, max). [changed to 65536, 262144]
    bFile = new Byte[iChunkSize];


    //Upload the file
    while ((iBytesRead = oFileStream.Read(bFile, 0, bFile.Length)) != 0)
    {
    oRequestStream.Write(bFile, 0, iBytesRead);
    iProcessedSoFar += iBytesRead;
    }

    //Get response of transfer
    oWResponse = oWebrequest.GetResponse();
    oResponseStream = oWResponse.GetResponseStream();
    oResponseReader = new StreamReader(oResponseStream);
    rsErr = oResponseReader.ReadToEnd();

  • What susb-status code for the 404 entry did you find in your IIS 7 log?

Comments have been disabled for this content.