Where can I find System.Web.HttpContext.Current.Server dll?

11,189

Solution 1

Right Click References >> then click Add Reference and Under Assemblies click Framework and Search System.Web and check the checkbox and click OK button to add it's reference in your project:

enter image description here

You have reference of System.Web now and Now you can use all Types and methods which are under System.Web namespace/assembly it, in your case HttpContext:

System.Web.HttpContext

Solution 2

System.Web.HttpContext.Current.Server isn't a namespace. Let's break it down:

  • System.Web is a namespace
  • HttpContext is a type (in the System.Web assembly)
  • Current is a static property within HttpContext, returning an HttpContext reference
  • Server is an instance property within HttpContext, of type HttpServerUtility

So the assembly you need is System.Web; the namespace you need in a using directive (if you want one) is System.Web.

So:

using System.Web;
...
var path = HttpContext.Server.Current.MapPath(...);

Note that a more modern equivalent is HostingEnvironment.MapPath, which doesn't rely on a current HTTP context, as far as I'm aware. (HostingEnvironment is in the System.Web.Hosting namespace, but still in the System.Web assembly.)

Solution 3

it's a sub of System.Web. you should add reference to System.Web.

Share:
11,189
Sivakumar Piratheeban
Author by

Sivakumar Piratheeban

I have almost two years experience in software development mostly in .net (C#, ASP.net, WPF, WCF) and database like SQL server 2012, SQL server 2008, SQL Server 2005,

Updated on June 04, 2022

Comments

  • Sivakumar Piratheeban
    Sivakumar Piratheeban almost 2 years

    Where can I find System.Web.HttpContext.Current.Server dll. I want to use Server.MapPath() in my code and it requires System.Web.HttpContext.Current.Server namespace. Even from references I couldn't find and add System.Web.HttpContext.Current.Server to my solution. Any help?