C
cssnow
I created the following method in a webservice on my localmachine web
host to test MapPath because it throws an exception in another method:
public class ProgramUpdateService : System.Web.Services.WebService
{
....
[WebMethod]
public string TestMethod()
{
string strtest = Server.MapPath("..\\");
return strtest;
}
I call the testmethod from a test client I have created. The client is
also running from my machine. The exception is an InvalidOperation,
and the message is: "HttpContext is not available. The class can only
be used in the context of an ASP.NET request."
As a side note, MapPath works fine when I call the method from a
browser by entering:
http://localhost/TestWVWProgramUpdate/TestWVWProgramUpdate.asmx
as the address, and using the form that ASP.NET creates.
I suppose that what the exception is telling me is that the code is not
running inside ASP.NET when called from the test client I created. How
is that possible?
host to test MapPath because it throws an exception in another method:
public class ProgramUpdateService : System.Web.Services.WebService
{
....
[WebMethod]
public string TestMethod()
{
string strtest = Server.MapPath("..\\");
return strtest;
}
I call the testmethod from a test client I have created. The client is
also running from my machine. The exception is an InvalidOperation,
and the message is: "HttpContext is not available. The class can only
be used in the context of an ASP.NET request."
As a side note, MapPath works fine when I call the method from a
browser by entering:
http://localhost/TestWVWProgramUpdate/TestWVWProgramUpdate.asmx
as the address, and using the form that ASP.NET creates.
I suppose that what the exception is telling me is that the code is not
running inside ASP.NET when called from the test client I created. How
is that possible?