IIS 8.5 file upload causing ‘NetworkError: 500 Internal Server Error

iis-8.5upload

I am having a terrible time trying to find the cause of the error when uploading a file (the size of the file does not matter) via HTTP to a Windows 2012 R2 Essentials (IIS 8.5) webserver.

The application runs flawlessly on Windows 2003 (IIS 6). It also runs great on my Windows 7 development PC running IIS 7.5

Since IIS Manager for IIS 7.5 is so similar to IIS 8.5, I had little difficulty in configuring my ISAPI web app but everything other than file uploads works fine.

I tested basic things first:

  • Just like in previous versions of IIS, I verified the upload folder permissions.
  • I checked Event Viewer and don’t see anything regarding my web app.
  • The request headers sent to the IIS 7.5 and IIS 8.5 versions are identical. The posted data is identical.
  • Set the maximum post size.
  • Added file types to the allow list.

Other things that I’ve tried:

When a large file is uploaded to the webserver, I see the w3wp.exe (32 bit process) consume CPU as the file uploads. The problem is that the error happens before any of my application code even gets a chance to work with the upload. For example:

// handle any HTTP POST
if (strcmp(spContext->GetRequestMethod(), "POST") == 0) {
    // what was posted?
    if (form == FILE_UPLOADED) {
        // A file has been uploaded.  Check it to make sure it is
        // not corrupt and do what I need to do with it.
        …
        // I then prepare a JSON response:
        m_HttpResponse.SetContentType("application/json; charset=UTF-8");
        …
        // Now send a reply to the client browser letting it know that the
        // file was either successfully / unsuccessfully handled
        …

I am guessing that it must be a IIS 8.5 configuration issue since this problem does not happen in IIS 7.5 or IIS 6.

Can someone give me their thoughts on what might be happening? Thank you!

UPDATE

Peter Hahndorf suggested that I use the Trace feature so I enabled it and this is the 'Request summary':

Url
http://www.fileuploads.tst:80/FileUpload.srf 

App Pool
DefaultAppPool_classic 

Authentication
anonymous 

User from token
NT AUTHORITY\IUSR 

Activity ID
{8000000F-0001-F800-B63F-84710C7967BB} 

Site
8 

Process
4652 

Failure Reason
STATUS_CODE 

Trigger Status
500 

Final Status
500 

Time Taken
0 msec 

Errors & Warnings
Severtity
Warning

Event
MODULE_SET_RESPONSE_ERROR_STATUS 

ModuleName
IsapiModule 

Notification
EXECUTE_REQUEST_HANDLER 

HttpStatus
500 

HttpReason
Internal Server Error 

HttpSubStatus
0 

ErrorCode
The operation completed successfully.
(0x0) 

ConfigExceptionInfo
this field is empty...nothing to display

Best Answer

After a week of going crazy, I finally found the root of the problem, it turned out to be the hard disk. It was making occasional clicking noises but I thought that it would not be a problem since I was only evaluating Windows 2012.

After all, Windows had loaded correctly and the only apparent problem was an occasional boot failure, but once the server was running, everything seemed to run smooth except for the file upload feature of my application.

Once the hard disk was replaced, the problem just vanished. No more internal server error when uploading any file!