我有一个包含以下代码的同步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);
}
Run Code Online (Sandbox Code Playgroud)
当我尝试从空的MVC4应用程序(NET 4.5)运行该模块时,我收到以下错误.
此时无法启动异步操作.异步操作只能在异步处理程序或模块中启动,或者在页面生命周期中的某些事件中启动.如果在执行页面时发生此异常,请确保将页面标记为<%@ Page Async ="true"%>.
我似乎错过了一些东西但是通过我的阅读,错误实际上不应该发生.
我有一个挖掘,但我似乎无法找到任何帮助,有没有人有任何想法?