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:
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.