The following guide shows the steps to implement an Ajax Uploader Control into ASP.NET MVC applications. If you haven't downloaded the software, please download it from here.

1. Install the assembly

Copy the assembly and license file to your application bin folder.


The UploadHandler.ashx file should be deployed to the application directory of your MVC website.

2. Add Uploader httpModule to web.config's httpModules list

To allow Ajax Uploader to handle upload requests, you need to add its HttpModule to your application.

IIS 5.0, 6.0 and IIS 7.0 Classic mode

CopyCode imageCopy Code
<configuration>
  <system.web>
    <httpModules>
      <add name="CuteWebUI.UploadModule" type="CuteWebUI.UploadModule,CuteWebUI.AjaxUploader"/>
     </httpModules>
  </system.web>
</configuration>

IIS 7.0 Integrated mode

CopyCode imageCopy Code
<configuration>
  <system.webServer>
    <modules>
      <add name="CuteWebUI.UploadModule" type="CuteWebUI.UploadModule,CuteWebUI.AjaxUploader"/>
    </modules>
  </system.webServer>
</configuration>

3. Using Ajax Uploader control in a MVC page (no razor)

a. Register Uploader control in MVC Controller

using (CuteWebUI.MvcUploader uploader = new CuteWebUI.MvcUploader(System.Web.HttpContext.Current))
{
   	uploader.UploadUrl = Response.ApplyAppPathModifier("~/UploadHandler.ashx");
   	uploader.Name = "myuploader";
   	ViewData["uploaderhtml"] = uploader.Render();
}
                

b. Insert an Uploader instance into the ASP.NET MVC page.

<% Html.BeginForm(); %>
   <%=ViewData["uploaderhtml"] %>
<% Html.EndForm(); %>
                

4. Using Ajax Uploader control in a MVC page (with razor)

a. Register Uploader control in MVC Controller

using (CuteWebUI.MvcUploader uploader = new CuteWebUI.MvcUploader(System.Web.HttpContext.Current))
{
   	uploader.UploadUrl = Response.ApplyAppPathModifier("~/UploadHandler.ashx");
   	uploader.Name = "myuploader";
   	ViewData["uploaderhtml"] = uploader.Render();
}

b. Insert an Uploader instance into the ASP.NET MVC page

@{Html.BeginForm();}
   @Html.Raw(ViewBag.uploaderhtml)
@{Html.EndForm();}
                


Send feedback about this topic to CuteSoft. © 2003 - 2017 CuteSoft Components Inc. All rights reserved.