Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AjaxFileUpload won't upload once site is published to IIS7 #424

Closed
ChrisWh71 opened this issue Mar 15, 2018 · 11 comments
Closed

AjaxFileUpload won't upload once site is published to IIS7 #424

ChrisWh71 opened this issue Mar 15, 2018 · 11 comments

Comments

@ChrisWh71
Copy link

ChrisWh71 commented Mar 15, 2018

I'm using VS2017 15.6.2 and AjaxControlToolkit 18.1.0
I've tried using the toolkit via both the NuGet package and via the installer.
I've added an Ajaxfileupload to my page. I've added the handler to system.webserver in my web.config, along with the appropriate config section settings for me to set the temp folder. I've tried this with temp folder overridden and without it set so it takes the default. I've also tried this with the UploadHandlerPath set in the asp and without. All the variants have the same result, which is...
When I run the website in VS2017 for IE11 the file uploader works just fine. When I publish it to our IIS server it wont upload any files, just returns the red error message. On our IIS server the website is running in an app pool under the network service account, and I've granted network service full control of the temp folder, but still the file upload fails on the server.
What am I doing wrong?
It's worth mentioning that I'm setting a list of AllowedFileTypes. When I try and upload a file not in this list the AjaxFileUploader reports that that file is not allowed because of the file type. This happens both when running the code in VS and on the server, so it seems as if the file uploader is at least processing the file in some way, just not uploading it (hence my mentioning the permissions on the temp folder).

@MikhailTymchukDX
Copy link
Contributor

Hi @ChrisWh71
Please specify the following:

  • The error message you see when trying to upload a file
  • An IIS application root path
  • A page path where AjaxFileUpload is placed
  • Screenshots of the Network tab in Chrome Developer tools when you try to upload a file, like this one:
    image

@ChrisWh71
Copy link
Author

The IIS application root is
http://gbvuts17/SalesReview/

The file upload control is on
http://gbvuts17/SalesReview/SalesDetails.aspx

This is what I see on screen...
ieerror

This is what I see in the console tab in IE11 F12 developers tools
error

This is what I see in the network tab in IE11 F12 developers tools (sorry, don't have Chrome)
network

This is the asp code. As you can see the file upload control is hidden in a collapsible panel extender
code

And here's a screenshot of the relevant pasrts of my web.config
config

@MikhailTymchukDX
Copy link
Contributor

@ChrisWh71

According to your screenshots, a web server error occurs.
Web server errors are logged in the Windows Events Log.
You can view it with Event Viewer.

Web server error 500 appears as a Warning from ASP.NET 4.0 source:
image

Please find the error event and post its error message here.

@ChrisWh71
Copy link
Author

ChrisWh71 commented Mar 19, 2018

I don't get any ASP.NET warnings in the event viewer in this instance. Here's the IIS Logs though. You can see I'm getting an 500.21 (Module not recognized) error.

POST /SalesReview/SalesReview/AjaxFileUploadHandler.axd contextKey={DA8BEDC8-B952-4d5d-8CC2-59FE922E2923}&controlID=ctl00_Content_AjaxFileUpload&fileId=EE9AE02C-2074-887E-912B-8A5D817C4A6E&fileName=Beach.jpg&chunked=false&firstChunk=true 80 ... Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+10.0;+WOW64;+Trident/7.0;+.NET4.0C;+.NET4.0E;+.NET+CLR+2.0.50727;+.NET+CLR+3.0.30729;+.NET+CLR+3.5.30729) 500 21 13 2

Here's the response body from the XMLHttpRequest

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>500 - Internal server error.</title>
<style type="text/css">
<!--
body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}
fieldset{padding:0 15px 10px 15px;} 
h1{font-size:2.4em;margin:0;color:#FFF;}
h2{font-size:1.7em;margin:0;color:#CC0000;} 
h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;} 
#header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS", Verdana, sans-serif;color:#FFF;
background-color:#555555;}
#content{margin:0 0 0 2%;position:relative;}
.content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}
-->
</style>
</head>
<body>
<div id="header"><h1>Server Error</h1></div>
<div id="content">
 <div class="content-container"><fieldset>
  <h2>500 - Internal server error.</h2>
  <h3>There is a problem with the resource you are looking for, and it cannot be displayed.</h3>
 </fieldset></div>
</div>
</body>
</html>

@MikhailTymchukDX
Copy link
Contributor

@ChrisWh71
Based on the error code you provided, I think your application runs in Classic application pool mode instead of Integrated mode.
Try switching it to the Integrated mode.

If it does not help, temporarily set a custom error mode to off in your application Web.config and check the server response again:

<configuration>
  <system.web>
    <customErrors mode="Off"/>
  </system.web>
</configuration>

@ChrisWh71
Copy link
Author

Our application pool is in Classic mode. Why would that make a difference?

@ChrisWh71
Copy link
Author

ChrisWh71 commented Mar 19, 2018

Some progress, but that's led to more questions...
I managed to get the file upload working when the site was moved to an integrated mode app pool, but only once I'd commented out the identity impersonate="true" line in the web.config. I think this is a non starter due to the way our security is set up.
So, in my mind this leads me to think its security related and something to do with the temp folder the uploader is using.
When I set IE to break on all errors in the debugger the code stops here...

doneAndUploadNextFile:function(e){var t=new XMLHttpRequest,i=this;t.open("POST","?contextKey="+this.get_contextKey()+"&controlID="+this.get_id()+"&done=1&guid="+e._id+this.getQueryString(),!0),t.onreadystatechange=function(n){if(4==t.readyState){if(200!=t.status||""==t.responseText)throw i.setFileStatus(e,"error",Sys.Extended.UI.Resources.AjaxFileUpload_error),i.raise_uploadError(t),"error raising upload complete event and start new upload";

Checking the XMLHttpRequest you can see the status is 200, OK, but the response text is empty, hence the reason the code raises this error.
capture

@MikhailTymchukDX
Copy link
Contributor

Managed handlers, which AjaxFileUploadHandler belongs to, can not be configured to run in IIS classic mode.

This article explains the difference between Classic and Integrated mode for modules and handlers: IIS 7.0, ASP.NET, pipelines, modules, handlers, and preconditions

@MikhailTymchukDX
Copy link
Contributor

@ChrisWh71

When I set IE to break on all errors in the debugger the code stops here...

Would you please provide a sample project that illustrates this issue? I cannot reproduce this behavior locally.

@ChrisWh71
Copy link
Author

Okay, that's interesting, thanks. At least we know now why it's not working and what to do to get it working. It's up to us now to decide what to do next based on the implications of this information. Thanks for all your help.

@MikhailTymchukDX
Copy link
Contributor

@ChrisWh71 You're welcome!
I consider the issue resolved, so I'm closing it.
Don't hesitate to comment if you have any info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants