I cant figure out how to get AjaxControlToolKit's AjaxFileUpload to allow uploading of all file types. I tried the below code but it doest work. Any help would be greatly appreciated.
<ajaxToolkit:AjaxFileUpload ID="AjaxFileUploader" runat="server" Width="100%" Style="padding-bottom: 10px" OnClientUploadStart="UploadStart" OnClientUploadCompleteAll="UploadEnd" AllowedFileTypes="*" AutoStartUpload="True"/>
this is what my web.config file looks like....
Here is what my config file and control markup looks like (after changes suggested by Albert D. Kallal)
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="devExpress">
<section name="themes" type="DevExpress.Web.ThemesConfigurationSection, DevExpress.Web.v22.2, Version=22.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" requirePermission="false" />
<section name="compression" type="DevExpress.Web.CompressionConfigurationSection, DevExpress.Web.v22.2, Version=22.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" requirePermission="false" />
<section name="settings" type="DevExpress.Web.SettingsConfigurationSection, DevExpress.Web.v22.2, Version=22.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" requirePermission="false" />
<section name="errors" type="DevExpress.Web.ErrorsConfigurationSection, DevExpress.Web.v22.2, Version=22.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" requirePermission="false" />
<section name="resources" type="DevExpress.Web.ResourcesConfigurationSection, DevExpress.Web.v22.2, Version=22.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" requirePermission="false" />
<section name="bootstrap" type="DevExpress.Web.Bootstrap.BootstrapConfigurationSection, DevExpress.Web.Bootstrap.v22.2, Version=22.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" requirePermission="false" />
</sectionGroup>
<section name="ajaxControlToolkit" type="AjaxControlToolkit.AjaxControlToolkitConfigSection, AjaxControlToolkit" requirePermission="false" />
</configSections>
<ajaxControlToolkit additionalUploadFileExtensions="dcm," />
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<add name="AjaxFileUploadHandler" verb="*" path="AjaxFileUploadHandler.axd" type="AjaxControlToolkit.AjaxFileUploadHandler,AjaxControlToolkit" />
<add type="DevExpress.Web.ASPxHttpHandlerModule, DevExpress.Web.v22.2, Version=22.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" verb="GET,POST" path="DX.ashx" name="ASPxHttpHandlerModule" preCondition="integratedMode" />
<add type="DevExpress.Web.ASPxUploadProgressHttpHandler, DevExpress.Web.v22.2, Version=22.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" verb="GET,POST" path="ASPxUploadProgressHandlerPage.ashx" name="ASPxUploadProgressHandler" preCondition="integratedMode" />
</handlers>
<modules runAllManagedModulesForAllRequests="true">
<add type="DevExpress.Web.ASPxHttpHandlerModule, DevExpress.Web.v22.2, Version=22.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" name="ASPxHttpHandlerModule" />
</modules>
<staticContent>
<mimeMap fileExtension=".dcm" mimeType="application/dicom" />
</staticContent>
</system.webServer>
<appSettings>
bla bla bla bla
...
<ajaxToolkit:AjaxFileUpload ID="AjaxFileUploader" runat="server" Width="100%" Style="padding-bottom: 10px" OnClientUploadStart="UploadStart" OnClientUploadCompleteAll="UploadEnd" AllowedFileTypes="dcm,zip" AutoStartUpload="True"/>
Ok, this is a bit of a un-documented issue.
While you "can" specify the file types that are allowed?
There are some "security" restrictions such as .msg files and a few others.
So, in web config, you can change this.
Add this right after the start in web.config, in "configuration"
like this:
<configuration>
<configSections>
<section name="ajaxControlToolkit"
type="AjaxControlToolkit.AjaxControlToolkitConfigSection, AjaxControlToolkit"
requirePermission="false"/>
</configSections>
<ajaxControlToolkit additionalUploadFileExtensions="msg" />
<appSettings>
.etc .etc. etc.
So, you MUST add the "section name", and then (and ONLY then), can you add the
additionalUploadFileExtensions part.
The ALLOWED list of file extenstions by default is this:
7z,aac,avi,bz2,csv,doc,docx,gif,gz,htm,html,jpeg,jpg,md,mp3,mp4
ods,odt,ogg,pdf,png,ppt,pptx,svg,tar,tgz,txt,xls,xlsx,xml,zip
NOTE very close, that "bmp" files are not in that list!!!
So, while you can filter/restrict/limit say zip and pdf like this:
<ajaxToolkit:AjaxFileUpload ID="AjaxFileUpload1" runat="server"
AllowedFileTypes="pdf,zip"
ChunkSize="8192"
OnClientUploadStart="UpLoadStart"
OnClientUploadComplete = "UpLoadCompleteOne"
OnClientUploadCompleteAll="UpLoadDone" ClientIDMode="Static"
ViewStateMode="Enabled"
OnClientUploadError="UpLoadError" title="" MaximumNumberOfFiles="20"
onchange="fileschanged();" />
so, in above, we ONLY allow the user pdf, zip.
However, if we added say :
AllowedFileTypes="pdf,zip,bmp,msg"
it will NOT allow this.
So, there is a biult in "list" of allowable file types.
You can change this. In web config, add this section:
<configuration>
<configSections>
<section name="ajaxControlToolkit"
type="AjaxControlToolkit.AjaxControlToolkitConfigSection, AjaxControlToolkit"
requirePermission="false"/>
</configSections>
<ajaxControlToolkit additionalUploadFileExtensions="msg" />
<appSettings>
<add key="ChartImageHandler" value="storage=file;timeout=20;dir=c:\TempImageFiles\;" />
Note carefull, the 2nd "additional" file element FIRST requires the config section above for the aj toolkit. So, look for a existing one, and if not, then add the above.
And for NO file extenstion?
This seems to work:
<ajaxControlToolkit additionalUploadFileExtensions="msg," />
Note the trailing "," in above.
As a FYI?
I believe the file "whitelist" or restrictions appeared around version 17 for the aj toolkit, and the current number is around 20 or so. (so, if you using later then version 17, then you will have to add the above to web.config to "allow" those file types regardless of the actual file types you specify for the ajaxfileupload control in the page markup.
Edit: allowing files without extensions
It turns out from testing, that web config does NOT have to be changed to allow files without extensions. The above white list of files (allowed) still remains, and if one wants to up-load say a simple "bmp" file, then one MUST change the web.config.
However, to allow files without a extension, no such changes to web.config is required, only that you use this in the list of allowed file types in the control's markup on the page.
eg:
AllowedFileTypes=",zip"
So, note the "empty" file type in above. (quite sure it has to be the first entry).
The above will thus allow up-loading of files without an extension.
Edit and follow up
It turns out that the web.config changes are NOT required to allow a file being up-loaded without a file extension.
All that is required is the in the control markup is to add a "empty" file type, say like this:
AllowedFileTypes=",zip"
So, a "empty" file type (no space) seems to work, and their is NOT a requirement to change the web config file.
However, do keep in mind that the advice about the built-in "white list" of allowed file types. This allowed list remains in effect for files with extensions.
So, for ANY type of file (extension) that is NOT in the white-list of files? Then yes, you do have to modify web.config, and then such files can be up-loaded. One can freely add "allowed" file types (extensions) to the markup tag on the page, or leave out the allowed file types attribute to allow all types of files.
In either case (using allowed file types or not attribute in markup), the allowed file type "list" has to be modified to allow files not in that default white-list of file types.
So, allowed file types tag/attribute is optional, but the allowed file types not in the above "white-list" of files requires a change to web.config for such files to be up-loaded.
I've looked at the related questions and followed their solutions, but it's still isn't working for me. Any help is appreciated, thank you.
I have a web application added as a virtual directory (under the parent site) and converted into an application. It even has its own application pool. The parent is .net 2.0 and child is .net 4.0.
The parent's Web.Config:
<configuration>
<configSections>
<sectionGroup name="system.web.extensions" ...>
<sectionGroup name="scripting" ...>
<section name="scriptResourceHandler" ... />
<sectionGroup name="webServices" ...>
<section name="jsonSerialization" ... />
<section name="profileService" ... />
<section name="authenticationService" ... />
</sectionGroup>
</sectionGroup>
</sectionGroup>
</configSections>
...
</configuration>
Child's Web.Config
<configurations>
<configSections>
<clear/>
</configSections>
<connectionStrings>
...
</connectionStrings>
</configuration>
My error message:
There is a duplicate 'system.web.extensions/scripting/scriptResourceHandler' section defined
The <clear/> doesn't work. I've also tried referencing the system.web.extensions block outside of <configSections>, and wrapping it in
<location path="." inheritInChildApplications="false">
and it still doesn't work.
I've also tried removing those sections in the child's Web.Config and it still doesn't work:
<configurations>
<configSections>
<remove name="system.web.extensions" />
</configSections>
<connectionStrings>
...
</connectionStrings>
</configuration>
At this point, I don't know what else to try. Is there a way to separate the child web application completely from the parent, but still retaining the parent's domain? I.E. I want to be able to access the child's website through www.parent.com/child.
Thanks again.
This link helped me: http://www.asp.net/whitepapers/aspnet4/breaking-changes#0.1__Toc245724860
I moved the into the root web.config (C:\Windows\Microsoft.NET\Framework64\v2.0.50727\CONFIG). After that, I wrapped each sections in the parent's web.config with
<location path="." inheritInChildApplications="false">
and it seems to be working now.
I copied the following web.config from the github paypal net sdk page, but got an error saying could not find schema information for the element ;Paypal'. Is there something wrong with my web.config syntax (this is for an asp.net website):
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configSections>
<section name="paypal" type="PayPal.SDKConfigHandler, PayPal" />
</configSections>
<!-- PayPal SDK settings -->
<paypal>
<settings>
<add name="mode" value="sandbox"/>
<add name="clientId" value="_client_Id_"/>
<add name="clientSecret" value="_client_secret_"/>
</settings>
</paypal>
</configuration>
Your code appears correct according to the documentation found here.
Are you sure that you have the appropriate references included for Paypal (via NuGet or manually)?
Additionally, you appear to be missing an opening <configuration> element, which could be an issue as well (unless that is just a typo) :
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<configSections>
<section name="paypal" type="PayPal.SDKConfigHandler, PayPal" />
</configSections>
<!-- PayPal SDK settings -->
<paypal>
<settings>
<add name="mode" value="sandbox"/>
<add name="clientId" value="_client_Id_"/>
<add name="clientSecret" value="_client_secret_"/>
</settings>
</paypal>
</configuration>
I am running IIS7.
I have a 3rd party dll that has its own config file. My understanding is that IIS7 will not read this config file and that I have to add it to the server web.config file.
However I get errors when adding a particular node.
In the dll.config it has:
<configuration>
<dllSettings>
--- bunch of settings....
</dllSettings>
</configuration>
So I added that same node into my web.config file...
Is there a parent node that I should add this to in my web.config?
When I have to add more config file. This is how I defined in the Web.Config
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="[NAMESPACE].[PROJECT].Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</sectionGroup>
</configSections>
<applicationSettings>
<[NAMESPACE].[PROJECT].Properties.Settings configSource="[NAMESPACE].[PROJECT].dll.settings.config"/>
</applicationSettings>
...
</configuration>
This is what I have in my other Config File
<?xml version="1.0" encoding="utf-8" ?>
<[PROJECT].Properties.Settings>
<setting name="[NAME]" serializeAs="String">
<value>Anything</value>
</setting>
</[PROJECT].Properties.Settings>
I want to rewrite:
Test.php to Default.asp
So I use the rule:
<rewrite url="~/Test.php" to="~/default.asp" />
But that rule gives a 404.
However this rule works fine:
<rewrite url="~/default.aspx" to="~/default.asp" />
But this rule 404's:
<rewrite url="~/Test" to="~/default.asp" />
My web.config:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<configSections>
<section name="rewriter"
requirePermission="false"
type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter" />
</configSections>
<system.web>
<httpModules>
<add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter" />
</httpModules>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule" />
</modules>
<validation validateIntegratedModeConfiguration="false" />
</system.webServer>
<rewriter>
<rewrite url="~/Test.php" to="~/default.asp" />
</rewriter>
</configuration>
What is PHP being handled by?
Per the setup documentation you need to ensure that the PHP extension is being handled by ASP.NET. In addition, if IIS is checking to see if the file exists before handing it off to ASP.NET you'd potentially be missing this as well.
Also, based on your system.webServer addition (which isn't detailed on the module's site), can we assume Server 2008? If so, can I recommend URL Rewrite instead?