4

I am writing/ have written a file upload portal for my company that requires the ability to upload a ton of different file types of various sizes and quantities. I used the AJaxControlToolkit AjaxFileUpload control.

The upload works well except when we upload what seems like IIS reserved file types. We can upload images, entire non-zipped folders, office docs etc.

When I try to upload the reserved file type the Firefox developer tools returns a server error, 'File Extension Not Allowed' error. This happens with .exe files and the one we need .stl files(in our case these are for 3d printing).

We have played with config files, Handler Mappings, HTTP response headers, MIME type configurations, and request filtering on the IIS manager at the app level, site level and server level and none seem to work.

The last bit of info is that zipping the file seems to get it through but we'd like to avoid asking the customer to do that.

IIS 8.5, C# .Net, Windows Server 2012 R2

I can post code if you need it but I am pretty sure it is a server configuration we need to change

Thanks for your help.

Walt

Edit: Below is my Config with the Fix included. this was an issue with white listed file types by the control and not the server. Thank you

<?xml version="1.0"?>
<configuration>
  <configSections>
    <section name="ajaxControlToolkit" type="AjaxControlToolkit.AjaxControlToolkitConfigSection, AjaxControlToolkit" requirePermission="false"/>
  </configSections>
  <appSettings/>
  <ajaxControlToolkit additionalUploadFileExtensions="bmp,stl"></ajaxControlToolkit>
  <system.webServer>
    <handlers>
      <add name="aa2" verb="*" path="AjaxFileUploadHandler.axd" type="AjaxControlToolkit.AjaxFileUploadHandler, AjaxControlToolkit"/>
    </handlers>  
  </system.webServer>
  <system.web>
    <compilation debug="true">
      <assemblies>
        <add assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add assembly="System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add assembly="System.Runtime.Serialization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
        <add assembly="System.Web.ApplicationServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add assembly="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
        <add assembly="System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
        <add assembly="System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
        <add assembly="System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
        <add assembly="System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
        <add assembly="System.Web.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
        <add assembly="System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
        <add assembly="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
        <add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
        <add assembly="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
        <add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
        <add assembly="System.Data.Services.Client, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
        <add assembly="System.Data.Services.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
        <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
        <add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
      </assemblies>
    </compilation>
    <pages>
      <controls>
        <add tagPrefix="ajaxToolkit" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit"/>
      </controls>
    </pages>
  </system.web>
</configuration>
  • 1
    Just curious why would FireFox Developer tools have anything to do with the issue. Can the files be uploaded to the server or not? Is the firefox issue preventing the upload? – JWP Jul 20 '17 at 12:55
  • 2
    No. Sorry for the confusion. I was just trying to provide all of the info I could so I was referring to the fact that I looked into the error using the dev tools and that error is what it told me was happening. – Walter Bennett Jul 20 '17 at 13:10

2 Answers2

4

You need to add the additionalUploadFileExtensions attribute to ajaxControlToolkit section in Web.config:

<ajaxControlToolkit additionalUploadFileExtensions="exe,stl" />

Please refer to this article: https://github.com/DevExpress/AjaxControlToolkit/wiki/AjaxFileUpload-setup

  • 1
    Thanks a ton. I think we're probably on the right path but I am not sure where in the config to add this line. I have a bare bones config except for the toolkit handler and the toolkit control added. I have added my config to the initial question. – Walter Bennett Jul 20 '17 at 13:29
  • 2
    I found it by doing some web searches using your input. and found that I needed to add a configSections section to the config and then I could add the line you told me to. Thanks so Much and good looking out since I steered the conversation wrong thinking it was a server issue. – Walter Bennett Jul 20 '17 at 15:12
-1

For an example of where to ajaxcontroltoolkit entry in the web.config file, please refer to Sample web.config Ajax configuration

Sample below:

<configuration>
  <configSections>
    <section name="ajaxControlToolkit" type="AjaxControlToolkit.AjaxControlToolkitConfigSection, AjaxControlToolkit" requirePermission="false"/>
  </configSections>
  <ajaxControlToolkit
    useStaticResources="true"
    renderStyleLinks="false"
    htmlSanitizer="AjaxControlToolkit.HtmlEditor.Sanitizer.DefaultHtmlSanitizer, AjaxControlToolkit.HtmlEditor.Sanitizer"
    tempFolder="~/Temp"/>
  <location path="Temp">
    <system.webServer>
      <handlers>
        <clear/>
      </handlers>
      <modules>
        <clear/>
      </modules>
    </system.webServer>
  </location>
<system.web>
RickyT
  • 1
  • 1
  • Hi! Welcome to Stack Overflow. To help the community better, it is often encouraged to include the linked code sample in your answer as well. This helps others find it easier and if the link becomes dead, the relevant information is kept forever in the answer. Could you please copy the relevant code to your answer. Thanks. Please see https://stackoverflow.com/help/how-to-answer for more info. – Michael Coxon Aug 03 '17 at 16:47