473,408 Members | 2,477 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,408 software developers and data experts.

namespace name 'Server' could not be found

in my class, i am trying to use Server.MapPath, but it says type or
namespace 'Server' can not be found.

i am using this in my webpages and it works fine. I thought maybe the
class was missing a using directive so i added all the same ones that
the webpages have but still no go.

anyone know what the problem is?
Dec 14 '05 #1
4 7537
Server is property of the Page class that your page inherits from, it not a
global. if you are trying to access from a class, use
HttpContext.Current.Server

-- bruce (sqlwork.com)
"Mortar" <a@b.com> wrote in message
news:43***************@nntp.broadband.rogers.com.. .
in my class, i am trying to use Server.MapPath, but it says type or
namespace 'Server' can not be found.

i am using this in my webpages and it works fine. I thought maybe the
class was missing a using directive so i added all the same ones that
the webpages have but still no go.

anyone know what the problem is?

Dec 14 '05 #2
Server is a property exposed by the Control class, unless your own class
also inherits from control (as do all pages, user controls and server
controls), it won't magically show up.

You can get a reference to the server class from your own class via:

HttpContext.Current.Server

note that if your class is consumed by a non-webclient, HttpContext.Current
will be null and thus you'll get a nullreference exception.

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Mortar" <a@b.com> wrote in message
news:43***************@nntp.broadband.rogers.com.. .
in my class, i am trying to use Server.MapPath, but it says type or
namespace 'Server' can not be found.

i am using this in my webpages and it works fine. I thought maybe the
class was missing a using directive so i added all the same ones that
the webpages have but still no go.

anyone know what the problem is?

Dec 14 '05 #3
a


it says type or namespace HttpContext not found.

do i need to add a using directive?
On Wed, 14 Dec 2005 13:22:35 -0800, "Bruce Barker"
<br******************@safeco.com> wrote:
Server is property of the Page class that your page inherits from, it not a
global. if you are trying to access from a class, use
HttpContext.Current.Server

-- bruce (sqlwork.com)
"Mortar" <a@b.com> wrote in message
news:43***************@nntp.broadband.rogers.com. ..
in my class, i am trying to use Server.MapPath, but it says type or
namespace 'Server' can not be found.

i am using this in my webpages and it works fine. I thought maybe the
class was missing a using directive so i added all the same ones that
the webpages have but still no go.

anyone know what the problem is?


Dec 16 '05 #4
a

disregard last message.

On Fri, 16 Dec 2005 12:01:52 -0500, a@b.com wrote:


it says type or namespace HttpContext not found.

do i need to add a using directive?
On Wed, 14 Dec 2005 13:22:35 -0800, "Bruce Barker"
<br******************@safeco.com> wrote:
Server is property of the Page class that your page inherits from, it not a
global. if you are trying to access from a class, use
HttpContext.Current.Server

-- bruce (sqlwork.com)
"Mortar" <a@b.com> wrote in message
news:43***************@nntp.broadband.rogers.com ...
in my class, i am trying to use Server.MapPath, but it says type or
namespace 'Server' can not be found.

i am using this in my webpages and it works fine. I thought maybe the
class was missing a using directive so i added all the same ones that
the webpages have but still no go.

anyone know what the problem is?


Dec 16 '05 #5

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

Similar topics

2
by: Matthew Louden | last post by:
using System.Data; using System.Data.SqlClient; //etc... SqlConnection conn = new SqlConnection(connString); SQLDataSetCommand myCmd = new SQLDataSetCommand("select * from Test;", conn);...
4
by: Rookie | last post by:
I have two C# VS .Net 2003 projects that compile and execute correctly on their own. I would like the second project to launch from within the first project. Therefore, I added the second...
3
by: Joe DeAngelo | last post by:
When I try to compile a source code which should normally run I got this error message error CS0246: The type or namespace name 'XmlSchemaSet' could not be found (are you missing a using...
2
by: Steve Richter | last post by:
I have a simple project that builds ok in Visual Web Developer, but which fails when I navigate to it at //localhost. The error is "namespace 'ac' could not be found". the problem page is at...
4
by: carqs123 | last post by:
What is the procedure for using a class defined in the same solution but in another project? The language I am using is c-sharp. I have a solution with two projects in it. A c-sharp program in...
1
by: robseflops | last post by:
Hi! I have a Asp.net 2.0 application that uses a masterpage. It works fine on the development machine but when I move the app to a Win 2003 server thinks go wrong: When I navigate to a page that...
2
by: chris.withers | last post by:
I've set up IIS on a local machine and have moved a site from my production server to this machine. Everything is copied over correctly. I next re-reference all the .dll's I built in c# to the bin...
4
by: vncntj | last post by:
I've tested this project locally, by running it http://localhost:1436/Data/gift.aspx and everything is perfect. But if it onto the remote server I get "The type or namespace name could not be...
2
by: Andrus | last post by:
I'm trying to compile myGeneration PropertyCollectionAll.cs file with VCS Express 2005 bot got error Error 1 The type or namespace name 'Collection' could not be found (are you missing a using...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.