Problem using "Server.MapPath"

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);
}
 
A

Anders Borum

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
--
 
G

Guest

Is it not sufficient to add system.Web namespace in the code?
System.Web.HttpContext.Current.Server is not available in object browser.
 
A

Anders Borum

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top