473,396 Members | 1,805 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

using Server.MapPath in vb class

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
3 6648
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: canasdaq | last post by:
Can anyone please help me. I was looking at the article "http://www.eggheadcafe.com/articles/20030603.asp". I am new to .net and know nothing in c#. I want to write a menu in asp.net. Can anyone...
0
by: Balakrsihna | last post by:
Hi All, Can anyone tell me how to replace an image in MS Word 2003 using c#.net. I am converting an html file to word doc and sending this as attachment using System.Web.Mail; the...
3
by: MattB | last post by:
If I use server.mappath to get to the root dir of my application from within codebehind, it works fine. I also want to use this from a vb class I have in my application, and I think I have an issue...
2
by: Scott | last post by:
Hi there, I am writing a webservice and am wanting to use Server.MapPath to get the path to some files on the server that is hosting the webservice. I am using VB.NET atm, but am learning C#, so...
1
by: mursyidatun ismail | last post by:
Dear all, database use: Ms Access. platform: .Net i'm trying to update a record/records in a table called t_doctors by clicking da edit link provided in the database. when i ran through da...
2
by: WB | last post by:
Hi, How can I access Server and Trace within a helper class? I have a webform that allows user to select a PDF file (on the web server) and render a jpeg image of that PDF file. The helper...
2
by: rn5a | last post by:
Using the FileSystemInfo class, I am retrieving all the directories & files existing in a particular directory on the server & listing them in a ListBox. If an item in the ListBox happens to be a...
9
by: WT | last post by:
Hello, I have code created with .net 1.0 and migrated to 3.5. Form 2.0 the XslTransform class is obsolete and the vs2008 compiler generates warnings that these classes are absolete suggesting to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.