Solved

The type or namespace name 'Server' could not be found (are you missing a using directive or an assembly reference?)

Posted on 2004-08-13
7
1,344 Views
Last Modified: 2008-01-09
I use "Server.UrlEncode" in my class, I also have the

using System.Web

directive. How can this sucker not be found?
0
Comment
Question by:RichardFox
7 Comments
 
LVL 17

Expert Comment

by:AerosSaga
ID: 11794108
did you import the system.web namespace?
0
 
LVL 7

Expert Comment

by:mdamico
ID: 11794118
0
 
LVL 17

Expert Comment

by:AerosSaga
ID: 11794152
if not try using system.web.httpserverutility.urlencode
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:RichardFox
ID: 11794215
AerosSaga, when you ask did I import the namespace, what do you mean? I thought the "using" directive was all I needed
0
 
LVL 17

Accepted Solution

by:
AerosSaga earned 125 total points
ID: 11794783
At the top of your class like so:

Imports System.Web.HttpServerUtility
Imports System.Security.Principal
Public Class _Default

Regards,

Aeros
0
 
LVL 20

Expert Comment

by:ihenry
ID: 11794863

Is this compile or run-time error?

Server is a property of System.Web.UI.Page class which is a shortcut to instance of HttpServerUtility class. You shouldn't be able to make a method call like "Server.UrlEncode" if your class is not System.Web.UI.Page or inherits from that class. If that is the case use HttpServerUtility.UrlEncode() instead.

Page.Server Property
http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemWebUIPageClassServerTopic.asp

HttpServerUtility.UrlEncode Method
http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemWebHttpServerUtilityClassUrlEncodeTopic.asp


HTH
0
 

Author Comment

by:RichardFox
ID: 11794903
Thanks folks, what really puzzled me was that i could call Server.UrlEncode in my Page_Load function (where the class is a child of System.Web.UI.Page), but not in another class which I defined myself. So I came to the same conclusion which jhenry spelled out, and qualified the UrlEncode function with System.Web.HttpUtility.UrlEncode()

THanks for the help
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ASP:Radiobuttonlist/asp:RadioButtonListItem custom styling 1 42
Web site error 3 41
Regex validation 2 25
asp enable view state 1 24
Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question