Server.MapPath() in non Page class

S

Steve

I have a class that I need to use Server.MapPath(), when I try to compile, I
get this error:
The type or namespace name 'Server' could not be found (are you missing a
using directive or an assembly reference?)

Are there any static members I can access outside the Page class to get to
MapPath?
 
K

Kevin Spencer

Assuming your class is operating in the context of an HttpRequest for an
ASPX page, refer to HttpContext.Current.Server.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Sometimes you eat the elephant.
Sometimes the elephant eats you.
 

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

Members online

No members online now.

Forum statistics

Threads
473,778
Messages
2,569,605
Members
45,238
Latest member
Top CryptoPodcasts

Latest Threads

Top