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,342 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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

708 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now