Problem using "Server.MapPath"

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

The sample code below returns and error " The type or namspace name 'Server'
could not be found". Please help.

using System;using System.IO; using System.Xml;using System.Diagnostics;
using System.Collections;using System.Web;using System.Web.UI;
using System.Web.UI.WebControls;using System.Web.UI.HtmlControls;
public class Business
{
XmlDocument doc = new XmlDocument();
doc.Load(Server.MapPath("Rules.xml"));
XmlElement root = doc.DocumentElement;
XmlNode context = root.SelectSingleNode("./bhRule[@ID='" + destination +"']");
XmlNode baseRule = context.SelectSingleNode("child::baseRule");
return (baseRule.InnerText);
}
 
Hello!

The Server object is available from the HttpContext.Current instance.

The fully qualified path is: System.Web.HttpContext.Current.Server.

venlig hilsen / with regards
anders borum
--
 
Is it not sufficient to add system.Web namespace in the code?
System.Web.HttpContext.Current.Server is not available in object browser.
 
Mikky, You need to specify some more code if you expect people to help.
Please provide a small set of sample code. I'll get back to you then.

Did you try the fully qualified name to the method?
 
Back
Top