Why I can't use Server.MapPath() in my class?

I have the following problem when I try to call the Server.MapPath(); inside a class.

It give to me the following error message:

Error 3 The name 'Server' does not exist in the current context C:\Develop\EarlyWarning\public\Implementazione\Ver2\PdfReport\iTextDocumentBase.cs 122 13 PdfReport

So I think that maybe I have to add the namespace related to the Server object but looking on the official documentation I can't found no related namespace: http://msdn.microsoft.com/en-us/library/ms525541%28v=vs.90%29.aspx

Why? What can I do to solve?



do like this in class:

System.Web.HttpContext.Current.Server.MapPath("Relative path");

In Case Of Websites you can use following code to access that object in .cs file

string strPath = System.Web.HttpContext.Current.Server.MapPath("YourDesired Path");

Server is object in the Page class so you need to inherit the Page class or get through Page class object. You can use System.Web.HttpContext.Current.Server in you do not need to use Page class.

Need Your Help

How to insert an array to a node js web service through angular js?

javascript arrays angularjs node.js

I am trying to insert an array of data to a node js web service. The code looks like this.

Can't draw thin lines with Java2D

java java-2d

I'm trying to draw a polygon with a stroke of 1 pixel. Because the entire polygon is scaled by 100, I set the line width to 0.01. For some reason though, the polygon gets drawn with an on-screen line