Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8054313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:07:07+00:00 2026-06-05T08:07:07+00:00

This problem only happens when I deploy this to our live server, it works

  • 0

This problem only happens when I deploy this to our live server, it works fine on my development machine in the visual studio web server, and it is only a problem in IE (8 & 9 both)

Posting a jpeg with this form…

<form method="post" id="uploadForm" enctype="multipart/form-data" action="/ImageUpload/UploadImageNew">
   <input type="file" onchange="postFile()" name="file"></div>
   <input type="submit" value="OK">
</form>

Using this javascript…

function postFile(ctrl) {
    document.getElementById('uploadForm').submit();
}

To this controller…

[HttpPost]
public ActionResult UploadImageNew(HttpPostedFileBase file)
{
    // Verify that the user selected a file
    if (file != null && file.ContentLength > 0)
    {
        file.SaveAs("AFilename.file");
     }
     else
     {
         throw new Exception("File not found")
     }
     return View("UploadImageNew");
}

Results in file.ContentLength = 0 in IE, but it works fine in FF & Chrome, the machine is on our Intranet if that makes any difference.

Any help greatly appreciated

UPDATE 1:

Weirdly it seems that the problem is intermittent, on Friday my colleague could not upload anything but I could, this morning it is me who can’t and my colleague can both using IE.

Everything seems to point to an IIS config problem?

UPDATE 2:

Ok, it looks like my issue is related to expired sessions / security. I am using a Hybrid Authentication Method and it is causing me problems.

The main site uses forms authentication, however I have another site which does windows authentication for me and sets the cookies, disabling this fixed the issue for me.

Not sure why yet but I think this would be better in another question.

I am marking smartcaveman’s answer as the right one, because his post lead to me to the right answer/explanation.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T08:07:09+00:00Added an answer on June 5, 2026 at 8:07 am

    Your issue has nothing to do with the IIS. It is broken because you are wiring up using the change event. There are known issues with IE and the change event. A table with the compatibility of different browsers with this event on different HTML elements is available at quirksmode.

    Here are a couple of blog articles on the subject:

    • http://passionatedevelopment.com/blog/2010/03/24/onchange-on-ie-vs-firefox-the-importance-of-cross-browser-test/
    • http://www.nofluffjuststuff.com/blog/scott_leberknight/2005/04/onclick_versus_onchange_in_ie_and_firefox

    The most obvious way that occurs to me to do this is to use the blur and focus methods instead. (Record a value on focus, check it on blur, and if it’s different submit).

    Update

    So, It’s still not working? Here’s a few other things that are worth looking into.

    1. What happens if you try to get the value from the form field on the client-side, prior to submitting. e.g. function postFile(ctrl) { alert(document.getElementById('uploadForm').value); return false; }. Does it have a value? Also, have you confirmed the feature works on the live environment without the JavaScript? (e.g. just submit the form normally). If it does, then you can be sure the problem is on the front end. If it doesn’t then the JS is fine and the problem is on the back-end.

    2. Max Request Length / Max Content Length. In a comment on your post, you said that you have enabled up to 2GB in the maxRequestLength. However, this works a little differently in IIS7 than in IIS6 (or Casini if that was your previous test environment). The details about this are cited in this blog, but in summary you need to make sure that your web.config has the setting in the system.webServer section, and that the value actually represents what you think it does. Details are in the article.

    3. Do you have exception handling and/or logging features in play? Is it possible you are swallowing an exception somewhere that is causing the request to be abandoned? Are there any empty try - catch blocks that might be protecting your view from an underlying error that would otherwise cause the request to fail? If you do have logging enabled, can you isolate a distinction between your attempted usage and your colleague’s?

    4. Is there anything different about the file structure on the live site than your development environment? I noticed you have a hard-coded form action /ImageUpload/UploadImageNew target, which could affect the application’s ability to match the incoming route.

    5. You said in the comment that the content length is 0, but if the test you used to determine this is what you have in the post, then you may be wrong. Your test is equivalent to file == null || file.ContentLength == 0). There are different implications depending on which is actually the case. If the file is null, then it may related to model binding. If the Content length is 0, then it at least recognized a file is being sent, but something goes wrong when it decides what to do about it. You can check to see if you are actually receiving the file data by looping through the HttpContext.Request.Form collection and writing out the values (That’s how we used to do it… in the ASP Classic days). This other post, Valum file upload – Works in Chrome but not IE, Image img = Image.FromStream(Request.InputStream) , says that a user with the same kind of issue found the file content in the Request.Files collection. You won’t know for sure until you check. Anyway, if the file data is in one of those places, you know that problem is happening in model binding (and you know the work around until you find the right way to fix it).

    6. I also found something on the Telerik forums that seems to describe something similar that happens with their component (which is really just a wrapper of what you are doing). It points to a possible session time out.

    I would suggest going through these items and seeing if any of them reveal more about the problem (at least #1 is sure to).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Note: This problem occurs only on Mac, on Windows works fine. I have a
First of all, this problem only happens in Firefox. Check this example page to
This is a bit of an obscure problem that only seems to happen when
This problem is only in IE. Consider the following HTML: <html> <body> <div style='position:absolute;left:1em;right:1em;top:1em;bottom:1em;overflow:auto;>
[Edit: This problem applies only to 32-bit systems. If your computer, your OS and
This problem exists for webkit browsers only chrome and possibly safari (i've not tested
I only have this problem in chrome. How remove the border around the image?
This problem is similar to when creating alternate colour table-rows, only we are dealing
My example is similar to this - The only problem is I cannot rewrite
First of all: This question is not directly programming related. However, the problem only

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.