Search code examples
c#.nethttpcontext

Can't find HttpContext in .NET 3.5 and Visual Studio 2008


I used code from here and I get the following error: Can't use HttpContext.Current.Server.MapPath()

In Visual Studio 2008 does the ContextMenuEntry "Solve" help you when you have missing references?

I already found out that HttpContext is not a member of System.Web in my IDE. According to Help > Info I am using .NET 3.5 SP1.

How do I get that running?

How do u usually react in this situation? What stuff do u look for in msdn.com?


Solution

  • What I would do in that situation is look on MSDN (or Google) for HttpContext. I did that, and it says it’s in System.Web. So make sure your project has a reference to System.Web.

    “Add Reference” menu item

    “System.Web” in the Add Reference dialog

    ... and then it seems to work:

    HttpContext is now available.