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?
Where can I find System.Web.HttpContext.Current.Server dll?
12.6k Views Asked by Sivakumar Piratheeban At
3
There are 3 best solutions below
0
On
System.Web.HttpContext.Current.Server isn't a namespace. Let's break it down:
System.Webis a namespaceHttpContextis a type (in theSystem.Webassembly)Currentis a static property withinHttpContext, returning anHttpContextreferenceServeris an instance property withinHttpContext, of typeHttpServerUtility
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.)
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:
You have reference of
System.Webnow and Now you can use all Types and methods which are underSystem.Webnamespace/assembly it, in your caseHttpContext:System.Web.HttpContext