473,700 Members | 2,349 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

what is SERVER a member of?

I have some functions that are reading/writing to the file system. As such,
they use server.mapPath a lot to navigate it all.

Since I'm using these functions numerous times throughout my application, I
thought I'd move these into their own .vb class file and reference them that
way.

The catch is when moving these scripts over, 'Server.MapPath ' turns into an
error "Name 'server' is not declared"

I'm assuming I need to expand Server.MapPath to show Server's parent class.
Alas, I have no idea what that is and google isn't helping much.

-Darrel
Nov 19 '05 #1
6 1602
From within a class, try using

System.Web.Http ServerUtility.M apPath

http://beta.asp.net/QUICKSTART/util/...pServerUtility


Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Espaņol
Ven, y hablemos de ASP.NET...
=============== =======

"darrel" <no*****@hotmai l.com> wrote in message
news:ev******** ******@TK2MSFTN GP15.phx.gbl...
I have some functions that are reading/writing to the file system. As such,
they use server.mapPath a lot to navigate it all.

Since I'm using these functions numerous times throughout my application, I
thought I'd move these into their own .vb class file and reference them that
way.

The catch is when moving these scripts over, 'Server.MapPath ' turns into an
error "Name 'server' is not declared"

I'm assuming I need to expand Server.MapPath to show Server's parent class.
Alas, I have no idea what that is and google isn't helping much.

-Darrel

Nov 19 '05 #2
From what I can tell this will not help the OP as the MapPath method is not
static

To reply to the original question. Server is an instance member of the Page
class (well, it's in several places but I assume page is where you're
normally getting it from) and is, as Juan pointed out, of type
HttpServerUtili ty.

If you want to call Server.MapPath from a utility function, you have 2
choices:

1. pass in the Server object from the page to the utility function.

2. Use HttpContext.Cur rent.Server.Map Path(). Through a bit of trickery
(well, thread local storage) this can dig out the server object associated
with the current request. N.B. If you call this function from a thread that
is not processing an HTTP request, it will barf at runtime.

HTH

Andy


"Juan T. Llibre" <no***********@ nowhere.com> wrote in message
news:%2******** *******@TK2MSFT NGP10.phx.gbl.. .
From within a class, try using

System.Web.Http ServerUtility.M apPath

http://beta.asp.net/QUICKSTART/util/...pServerUtility


Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Espaņol
Ven, y hablemos de ASP.NET...
=============== =======

"darrel" <no*****@hotmai l.com> wrote in message
news:ev******** ******@TK2MSFTN GP15.phx.gbl...
I have some functions that are reading/writing to the file system. As
such,
they use server.mapPath a lot to navigate it all.

Since I'm using these functions numerous times throughout my application,
I
thought I'd move these into their own .vb class file and reference them
that
way.

The catch is when moving these scripts over, 'Server.MapPath ' turns into
an
error "Name 'server' is not declared"

I'm assuming I need to expand Server.MapPath to show Server's parent
class.
Alas, I have no idea what that is and google isn't helping much.

-Darrel


Nov 19 '05 #3
> From what I can tell this will not help the OP as the MapPath method is
not
static
I'm not quite sure what you mean by that.

Specifically, I'm taking a virtual path:

/documents/shared/ and mapping it to the actual server, be it my local one
when testing or the live server when deploying.

To reply to the original question. Server is an instance member of the Page class
Ah! Well, that explains it.
2. Use HttpContext.Cur rent.Server.Map Path(). Through a bit of trickery
(well, thread local storage) this can dig out the server object associated
with the current request. N.B. If you call this function from a thread that is not processing an HTTP request, it will barf at runtime.


This may be a naive question, but aren't all ASP.net threads part of a HTTP
request (ie, postbacks?)

-Darrel
Nov 19 '05 #4
> From what I can tell this will not help the OP as the MapPath method is not static

I wasn't looking too closely.

Thanks !
Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Espaņol
Ven, y hablemos de ASP.NET...
=============== =======

"Andy Fish" <aj****@blueyon der.co.uk> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
From what I can tell this will not help the OP as the MapPath method is not static

To reply to the original question. Server is an instance member of the Page class (well,
it's in several places but I assume page is where you're normally getting it from) and
is, as Juan pointed out, of type HttpServerUtili ty.

If you want to call Server.MapPath from a utility function, you have 2 choices:

1. pass in the Server object from the page to the utility function.

2. Use HttpContext.Cur rent.Server.Map Path(). Through a bit of trickery (well, thread
local storage) this can dig out the server object associated with the current request.
N.B. If you call this function from a thread that is not processing an HTTP request, it
will barf at runtime.

HTH

Andy


"Juan T. Llibre" <no***********@ nowhere.com> wrote in message
news:%2******** *******@TK2MSFT NGP10.phx.gbl.. .
From within a class, try using

System.Web.Http ServerUtility.M apPath

http://beta.asp.net/QUICKSTART/util/...pServerUtility


Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Espaņol
Ven, y hablemos de ASP.NET...
=============== =======

"darrel" <no*****@hotmai l.com> wrote in message
news:ev******** ******@TK2MSFTN GP15.phx.gbl...
I have some functions that are reading/writing to the file system. As such,
they use server.mapPath a lot to navigate it all.

Since I'm using these functions numerous times throughout my application, I
thought I'd move these into their own .vb class file and reference them that
way.

The catch is when moving these scripts over, 'Server.MapPath ' turns into an
error "Name 'server' is not declared"

I'm assuming I need to expand Server.MapPath to show Server's parent class.
Alas, I have no idea what that is and google isn't helping much.

-Darrel



Nov 19 '05 #5

"darrel" <no*****@hotmai l.com> wrote in message
news:Ow******** ******@TK2MSFTN GP09.phx.gbl...
From what I can tell this will not help the OP as the MapPath method is not
static


I'm not quite sure what you mean by that.


a static method of a class is one which you can invoke independently of
having an instance of that class - it's more like a global function. read up
on OO concepts if you're not clear on this.

Specifically, I'm taking a virtual path:

/documents/shared/ and mapping it to the actual server, be it my local one
when testing or the live server when deploying.

so either of my proposed solutions should work for you
To reply to the original question. Server is an instance member of the Page
class


Ah! Well, that explains it.
2. Use HttpContext.Cur rent.Server.Map Path(). Through a bit of trickery
(well, thread local storage) this can dig out the server object
associated
with the current request. N.B. If you call this function from a thread

that
is not processing an HTTP request, it will barf at runtime.


This may be a naive question, but aren't all ASP.net threads part of a
HTTP
request (ie, postbacks?)


yes (assuming the thread was created by asp.net to handle a request). I was
just making the point that if, for whatever reason, you call that function
from another thread (one you have started yourself or when including this
same utility function in a different application) it won't work

-Darrel

Nov 19 '05 #6
> yes (assuming the thread was created by asp.net to handle a request). I
was
just making the point that if, for whatever reason, you call that function
from another thread (one you have started yourself or when including this
same utility function in a different application) it won't work


Thanks, Andy. I appreciate the explanations!

-Darrel
Nov 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2509
by: Paul J. Landry | last post by:
HI Guys. I hope you can help me out! I'm writting a small app for my Intranet that allows me to see basic information aount user accounts. Included in that information is disk quota data such as QuotaLimit, QuotaUsed and such. If the quota info is from a disk local to my IIS server, such as it's drive C. Everything works fine. However, this is where the fun starts!
12
3300
by: Steven T. Hatton | last post by:
This is something I've been looking at because it is central to a currently broken part of the KDevelop new application wizard. I'm not complaining about it being broken, It's a CVS images. Such things happen. The whole subsystem is going through radical changes. I don't really want to say what I think of the code just yet. That would influence the opinions of others, and I really want to know how other people view these things,...
3
15365
by: Bryan | last post by:
We created a Windows Service with C#. The service will start OK on computers that are a member of a domain, but when we try to start it on a server that is configured for a workgroup we get the following error in the event log: Event ID: 7001 Description: The {Service Name}service depends on the Net Logon service which failed to start because of the following error: The service has returned a service-specific error code.
3
5522
by: Steve Wark | last post by:
I have a Windows 2003 Web server on which I was debugging remotely with no problems. I then moved this server to a different domain and now remote debugging will not work, the error is; Auto-attach to process ' w3wp.exe' on machine 'CSS5' failed. Error code 0x80070005 (Access is denied. ). I have found a number of articles and it would appear that the problem
4
1307
by: Eidolon | last post by:
We have a Win2K3 Web Edition server. I have the remote components installed and am trying to attach to debug, but i cant find what process to attach to. On Win2K its aspnet_wp.exe. That process doesnt even exist on the 2K3 box though. I tried inetinfo.exe and w3wp.exe, both to no avail. Thanks in advance,
2
4921
by: Mike | last post by:
Hi, I am strugling with a simple problem which I can't seem to resolve. I have an asp.net page which contains a server-control (flytreeview, which is a kind of a tree to be exact). The tree is being updated by some other process through remoting. When the page loads, I init the tree, and in my browser I can see the initialized tree. The problem is that every time that I receive update to tree from the remote process,
6
1208
by: SlashDrew | last post by:
I have created a custom control that has some design time support. I can create a menubar with the following HTML <Menu:BarMenu runat="server" id="MenuBar"> <MainMenuItems> <Menu:BarMenuItem Text="New Member" id="btnNewMember" onclick="btnNewMember_Click" MenuTip="Click to Add a new Member" /> <Menu:BarMenuItem Text="Edit Profile" id="btnEditProfile" disabled onclick="btnEditProfile_Click" MenuTip="Click to Edit the selected Member's...
1
1739
by: =?Utf-8?B?am9uZWZlcg==?= | last post by:
I keep getting the message after I converted a regular aspx page to now be based on a master page: "Only Content controls are allowed directly in a content page that contains Content controls." What control, or line of Code is causing the error? here is the offending code :
1
1906
by: ringoschplingo | last post by:
Hi, (sorry this is a long one) I have MSSQL 2000 (version 8.00.2187) installed on Windows Server 2K3, nothing 'special' has been done to either of these servers as far as configuration goes. The exact details of the Windows server are Version - 5.2.3790, SP1. In order to query an Oracle db from SQL, I've set up a linked server within SQL that uses a DSN to connect to the Oracle system. I use ADO to connect to SQL with integrated...
0
8645
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9214
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9075
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8973
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5903
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4404
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4657
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3089
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2028
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.