Previous Next

Thread: error: (500) Internal Server Error on Win 2008 64 bit

Last post 09-19-2008 8:59 AM by steve schofield. 3 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (4 items)

Sort Posts:

  • 09-18-2008, 6:38 AM

    error: (500) Internal Server Error on Win 2008 64 bit

    Hi All,

    I'm developing a win app(VS 2008) which should upload a file at a time to a web site, the IIS 7 runs on win 2008 64bit OS. but it gives me "The remote server returned an error: (500) Internal Server Error." error. but the same code is work fine on win XP 32bit with IIS6.

    not only that; I couldn't get the PUT command working with IIS7 too, that's why I selected the POST, does IIS dropped the feature from IIS6 to IIS7?

    Win App

    private void button1_Click(object sender, EventArgs e){

    WebClient wc = new WebClient();

    wc.UploadFile("http://localhost/WEBFileUpload/Default.aspx", "POST", @"E:\SoftWare\" + fileName);

    }

    Web App

    byte[] buffer = new byte[10240];

    int bytesRead = 0;

    protected void Page_Load(object sender, EventArgs e)

    {

    Stream file = Request.Files[0].InputStream;

    FileStream remoteFile = new FileStream(Server.MapPath(@"Data\" + Request.Files[0].FileName), FileMode.CreateNew, FileAccess.Write, FileShare.None);

    while ((bytesRead = file.Read(buffer, 0, buffer.Length)) != 0)

    {

    remoteFile.Write(buffer, 0, bytesRead);

    remoteFile.Flush();

    }

    remoteFile.Close();

    }

    --------------------------------------------------------------------

    PUT mrthod WebClient wc = new WebClient();

    HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://localhost/WEBFileUpload/Data/" + uri);

    request.Method = "PUT";

    request.ContentLength = resource.Length;

    request.AllowWriteStreamBuffering =
    false;

    request.Timeout = int.MaxValue;

    using (Stream requestStream = request.GetRequestStream())

    {

    byte[] buffer = new byte[4096];

    int bytesRead = 0;

    try

    {

    while ((bytesRead = resource.Read(buffer, 0, buffer.Length)) != 0)

    {

    requestStream.Write(buffer, 0, bytesRead);

    requestStream.Flush();

    }

    }

    catch (IOException e)

    {

    throw e;

    }

    requestStream.Close();

    }

    try

    {

    request.GetResponse();

    }

    catch (WebException e)

    {

    throw e;

    }

     

    Thanks,

    Samantha Bandara

  • 09-18-2008, 2:24 PM In reply to

    Re: error: (500) Internal Server Error on Win 2008 64 bit

    Can you post the complete 500 error?  This will help troubleshoot further.

    Steve Schofield
    Windows Server MVP - IIS
    http://weblogs.asp.net/steveschofield

    http://www.IISLogs.com
    Log archival solution
    Install, Configure, Forget
  • 09-19-2008, 3:38 AM In reply to

    Re: error: (500) Internal Server Error on Win 2008 64 bit

    Hi Steve,

    thanks you very much for fast reply. I found the issue with the WebClient.UploadFile() method, it is the file size, it can handle only 4MB.

    but my clients required to upload bigger files (may be 4GB or so). I think the bet is to use PUT command, but I found an issue with PUT command,

    The PUT command not create the file at server end even though I Flush the stream, and when I try to  access the file it returns error 500, which is obvious.BUT it works on IIS6 32 Bit

    1          DOES  the IIS7 support for PUT?2          On Flush, to where it get flush if the file not physical on the location that I specified?--------- My Code for PUT --------- WebClient wc = new WebClient();
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://localhost/WEBFileUpload/Data/" + uri);
               
    request.Method = "PUT";
    request.ContentLength = resource.Length;
    request.AllowWriteStreamBuffering = false;
    request.Timeout = int.MaxValue;
    request.ContentType = "application/octet-stream";using (Stream requestStream = request.GetRequestStream())
    {
     byte[] buffer = new byte[4096];
     int bytesRead = 0;
     try
          {
           while ((bytesRead = resource.Read(buffer, 0, buffer.Length)) != 0)
                {
                 requestStream.Write(buffer, 0, bytesRead);
                      requestStream.Flush();
                }
          }
          catch (Exception e)
          {
           throw e;
     }
          requestStream.Close();
    }
    try
    {
     request.GetResponse();
    }
    catch (Exception e)
    Thanks,Samantha
  • 09-19-2008, 8:59 AM In reply to

    Re: error: (500) Internal Server Error on Win 2008 64 bit

    Yes both IIS 6 and IIS 7 support PUT requests.  That is a pretty standard HTTP reply.  For doing very large uploads, I would look at using SAFileup http://www.safileup.com/  it can handle very large uploads,

    What is the metabase setting for AspMaxRequestEntityAllowed?

    http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/a6401b5e-c902-4035-90aa-ee46c270d357.mspx?mfr=true

     

    Steve Schofield
    Windows Server MVP - IIS
    http://weblogs.asp.net/steveschofield

    http://www.IISLogs.com
    Log archival solution
    Install, Configure, Forget
Page 1 of 1 (4 items)
Page view counter