HttpContext not available in Class Library

后端 未结 3 749
忘了有多久
忘了有多久 2021-01-07 19:08

I am working on a project where I have a C# class library which needs to use the System.web.HttpContext. I\'ve done this before in another project without probl

相关标签:
3条回答
  • 2021-01-07 19:31

    Just to add some input incase someone else gets hung up on this. If you are in a Unit test project or a Class Library that links back to an MVC project, you may have references to System.Web.Mvc. This DOES NOT INCLUDE System.Web. You must add both if you need something Mvc specific (like a SelectList) AND HttpContext

    0 讨论(0)
  • 2021-01-07 19:44

    Despite your comment that you've added reference to System.Web to the project it is still most likely reason of what you are seeing.

    The classes you see are coming from System.Dll, not System.Web.Dll.

    0 讨论(0)
  • 2021-01-07 19:46

    This means that either you are using a Client Profile as the Target Framework or the reference to System.Web was not added correctly.

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