【发布时间】:2013-07-25 16:04:33
【问题描述】:
我有一个包含以下代码的同步 HttpModule。
/// <summary>
/// Occurs as the first event in the HTTP pipeline chain of execution
/// when ASP.NET responds to a request.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">An <see cref="T:System.EventArgs">EventArgs</see> that
/// contains the event data.</param>
private async void ContextBeginRequest(object sender, EventArgs e)
{
HttpContext context = ((HttpApplication)sender).Context;
await this.ProcessImageAsync(context);
}
当我尝试从空的 MVC4 应用程序 (NET 4.5) 运行模块时,出现以下错误。
此时无法启动异步操作。异步 操作只能在异步处理程序中启动或 模块或页面生命周期中的某些事件期间。如果这 执行页面时发生异常,请确保该页面是 标记为 。
我似乎遗漏了一些东西,但根据我的阅读,错误实际上不应该发生。
我四处寻找,但似乎找不到任何帮助,有人有什么想法吗?
【问题讨论】:
标签: asp.net-mvc async-await httpmodule