By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,812 Members | 863 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,812 IT Pros & Developers. It's quick & easy.

using Server.MapPath in vb class

P: n/a
Server.MapPath works fine for me in a CodeBehind file, but when I try and
move that code to a vb class it doesn't. What do I need to change to make
Server.MapPath work from my vb class? Thanks!

Matt
Nov 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Since you are using Server, I suspect the class needs to be passed the
Httpcontext.

"The HttpContext.Server property provides programmatic access to the
properties and methods of the HttpServerUtility class. Because ASP.NET pages
contain a default reference to the System.Web namespace (which contains the
HttpContext class), you can reference the members of HttpContext on an .aspx
page without the fully qualified class reference to HttpContext. For
example, you can use just Server.CreateObject("MyCOMComponent") to create an
instance of a COM object on the server. If you want to use the members of
HttpServerUtility from an ASP.NET code-behind module, however, you must
include a reference to the System.Web namespace in the module and also fully
qualify the reference to the currently active request/response context and
the class in System.Web you want to use. For example, in a code-behind page
you must specify the full name
HttpContext.Current.Server.CreateObject("MyCOMComp onent"). "

http://msdn.microsoft.com/library/de...ervertopic.asp

"MattB" <so********@yahoo.com> wrote in message
news:2g************@uni-berlin.de...
Server.MapPath works fine for me in a CodeBehind file, but when I try and
move that code to a vb class it doesn't. What do I need to change to make
Server.MapPath work from my vb class? Thanks!

Matt


Nov 18 '05 #2

P: n/a
Make sure you are importing all the required Namespaces (System.Web)

If you have imported it and still having error, you will need to post error message to get any valuable commen

Kamran
Nov 18 '05 #3

P: n/a
Access it like this HttpContext.Current.server.transfer("..")

--
Saravana
http://dotnetjunkies.com/WebLog/saravana/
www.ExtremeExperts.com
"MattB" <so********@yahoo.com> wrote in message
news:2g************@uni-berlin.de...
Server.MapPath works fine for me in a CodeBehind file, but when I try and
move that code to a vb class it doesn't. What do I need to change to make
Server.MapPath work from my vb class? Thanks!

Matt

Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.