Server.MapPath

G

Gregory A. Beamer

What is syntax for Server.MapPath when I am in a class module? Thanks.

Leszek has the answer. You also have to reference the web assembly to
use it.

NOTE: If this class library is not a UI library, I would not do it this
way. You are tightly coupling the library to the an ASP.NET UI, which
means you cannot easily refactor the application to any other type of
UI. If this is a UI only library, then there is no issue, of course.

Peace and Grace,

--
Gregory A. Beamer (MVP)

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************
 
G

Gregory A. Beamer

HttpContext.Current.Server.MapPath("path");

The only potential issue I have with this is if the class library is a
business layer (middle tier) assembly. This code will tightly couple the
library to an ASP.NET UI.

Peace and Grace,

--
Gregory A. Beamer (MVP)

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************
 
L

Leszek

You're sure right Gregory. Using HttpContext tights the code to the ASP.NET
layer (we need to be in the HTTP Context in order to use the HttpContext :).
I understand that David's question referred to a class within the App_Code
folder (David said: "a class module") which is a part of the web
application.

If the "class module" means a class defined in an external assembly
referenced by David's ASP.NET application it also would have access to the
HttpContext. It is common to develop a set of WebControls as an additional
assembly. These controls would have access to the application's HttpContext.

The caveat of using HttpContext is pointed by Gregory:
"you cannot easily refactor the application to any other type of UI"
than ASP.NET

Cheers,
Leszek
 

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

Similar Threads

Server.MapPath 2
Server.MapPath & Request.MapPath 4
using Server.MapPath in vb class 3
server.mappath 4
Path=Server.MapPath 3
Path 1
Server.mappath 7
Server.MapPath("/") doesnt work 5

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top