HI, after my first struggle to get this to work i finely found a way, i just want to share this
to every one that use iis7 asp.net 4.0 and C# / VB.
(there is still 1 big issue that should be focus on, i wrote info about that in the end here, but there is a solution to it)
Before i start i just want to say a few words. There are not many good Upload controllers out there, that support all browsers.
I think i tried every one that is on the web. (will not recommend obout or telerik). More i worked with this,
more i see how much work have been done to this AjaxUploader controller. This uploader does not interfere with any
of my other codes. I am really happy how flexible this controller works.
Web.config: <appSettings>
<add key="CuteWebUI.AjaxUploader.TempDirectory" value="~/Tempfolder"/>
<add key="CuteWebUI.AjaxUploader.GlobalMaxSizeKB" value="2097151"/>
</appSettings>
<system.web>
<assemblies>
<add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
</assemblies>
### Start Classic Application Pool Mode (doest not work in Integrated Application Pool mode) ###
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
</httpHandlers>
<httpModules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="CuteWebUI.UploadModule" type="CuteWebUI.UploadModule,CuteWebUI.AjaxUploader"/>
</httpModules>
</system.web>
### End Classic Application Pool Mode ###
<httpRuntime maxRequestLength="2097151" executionTimeout="1200" />
<pages viewStateEncryptionMode="Never" enableEventValidation="false" controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID" autoEventWireup="true" validateRequest="false" />
### Integrated Application Pool modules ###
<system.webServer>
<modules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="CuteWebUI.UploadModule" type="CuteWebUI.UploadModule,CuteWebUI.AjaxUploader"/>
</modules>
</system.webServer>
the aspx page header:
<%@ Register TagPrefix="CuteWebUI" Namespace="CuteWebUI" Assembly="CuteWebUI.AjaxUploader" %>
<%@ Register TagPrefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<CuteWebUI:Uploader runat="server" ID="Uploader1" InsertText="Upload File" OnFileUploaded="Uploader_FileUploaded"></CuteWebUI:Uploader><br />
<asp:Button ID="ButtonPostBack" Text="Save" runat="server" OnClick="ButtonPostBack_Click" Width="54px" /><br />
<asp:Literal runat="server" ID="txtinfoBox"></asp:Literal>
The codebehind:
using System.IO;
using System.Text;
using CuteWebUI;
protected void Uploader_FileUploaded(object sender, UploaderEventArgs args)
{
Session["FileName"] = args.FileName;
string PathX = Server.MapPath("../files/");
string filename = Convert.ToString(Session["FileName"]);
if (File.Exists(PathX + filename) == true)
{
txtinfoBox.Text += "<br /> Filen " + filename + " File was overwritten in " + PathX + " <br />";
File.Delete(PathX + filename);
}
args.MoveTo("../files/" + args.FileName);
txtinfoBox.Text += "Status: <b>" + filename + "</b> Was saved" + "<hr>";
}
This works just great, you can use this also in a usercontroll without any problem, just make sure
you dont access the page with Folder/ without the Default.asp in the link else you get a error. (thx for clearing that up Keeneth)
My urly problem was that this code didnt work without the HttpHandlers and HttpModules. And if i added it to the server, it
dident load the page because this is not supported by iis7 in Integrated Application Pool mode, you can use :
<configuration>
<!-- This is for Classic Application Pool -->
<system.web>
<httpModules>
<add name="IntranetPageHttpModule" type="CoTs.Intranet.IntranetPageHttpModule" />
</httpModules>
<httpHandlers>
</httpHandlers>
</system.web>
<!-- This is for Integrated Application Pool -->
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules>
<add name="IntranetPageHttpModule" type="CoTs.Intranet.IntranetPageHttpModule" />
</modules>
<handlers>
</handlers>
</system.webServer>
</configuration>
I hope Cutesoft make this great controller without the need of httpHandlers and httpModules since this are discontinued in iis7.
Thank you!