System.Web.HttpContextBase' does not contain a definition for 'Current' MVC 4 with Elmah Logging

后端 未结 1 1197
被撕碎了的回忆
被撕碎了的回忆 2020-12-03 09:28

I have a C# ASP.NET MVC 4 project, which is using Elmah for catching any unhandled exceptions. This works great in most situations.

However I\'ve found that for a

相关标签:
1条回答
  • 2020-12-03 10:19

    To get a reference to HttpContext.Current you need replace

    HttpContext.Current
    

    with

    System.Web.HttpContext.Current
    

    This is because Controller class defines a property named HttpContext that is defined as

    public HttpContextBase HttpContext { get; }
    

    HttpContext on Controller class returns HttpContextBase which does not have a Current property.

    Hence you need to properly resolve the namespace here.

    0 讨论(0)
提交回复
热议问题