在Asp.net网站表单中。 使用Blueimp Jquery文件上传。
我的Backload示例中的代码如下所示(在FileHandler.ashx.cs中):
namespace BackloadTest
{
public class FileHandler : HttpTaskAsyncHandler
{
/// <summary>
/// File handler demo for classic Asp.Net or HTML.
/// To access it in an Javascript ajax request use: <code>var url = "/Handler/FileHandler.ashx";</code>.
/// </summary>
/// <remarks>
/// NOTE. Edit the web.config file to allow the DELETE method in the system.webServer.handlers section
/// </remarks>
public override async Task ProcessRequestAsync(HttpContext context)
{
try
{
// Wrap the request into a HttpRequestBase type
HttpRequestBase request = new HttpRequestWrapper(context.Request);
// Create and initialize the handler
IFileHandler handler = Backload.FileHandler.Create();
handler.Init(request);
// Call the execution pipeline and get the result
IBackloadResult result = await handler.Execute();
// Write result to the response and flush
ResultCreator.Write(context.Response, result);
context.Response.Flush();
}
catch
{
context.Response.StatusCode = 500;
}
}
}
}
但是,我想将此代码放在我的页面的aspx.cs文件中(而不是.ashx.cs),因为在该页面上我必须在收到上传的文件后做一些额外的处理,例如更新我的数据结构,刷新网格视图等。
我该怎么做?