does not exist in the current context

J

J

I'm trying to use HttpUtility.UrlEncode method but I get this error "The
name 'HttpUtility' does not exist in the current context". After adding
"using System.Web", then typing in System.Web., IntelliSense just shows 3
methods available (AspNetHostingPermission,AspNetHostingPermissionAttribute,
and AspNetHostingPermissionLevel) but no HttpUtility. What's up?

Thx,
-j

Code snip:

using System;
using System.Text;
using System.Net;
using System.IO;
using System.Web;

namespace XYZtest
{
class Program
{
static void Main(string[] args)
{
PostInfo();
}
private static void PostInfo()
{
string postData="UID=me";
postData += ("&PWD=mypassword");
postData += ("&DATA=mydata");
postData = HttpUtility.UrlEncode(postData));
 
H

Hans Kesting

I'm trying to use HttpUtility.UrlEncode method but I get this error "The name
'HttpUtility' does not exist in the current context". After adding "using
System.Web", then typing in System.Web., IntelliSense just shows 3 methods
available (AspNetHostingPermission,AspNetHostingPermissionAttribute, and
AspNetHostingPermissionLevel) but no HttpUtility. What's up?

Did you add a reference to System.Web.dll to your project? That is more
important than a "using" clause, as that is no more than a "type
saving" device (meaning: less to type in).

Hans Kesting
 
J

J

Thanks for clearing that up for this newbie.

Hans Kesting said:
Did you add a reference to System.Web.dll to your project? That is more
important than a "using" clause, as that is no more than a "type saving"
device (meaning: less to type in).

Hans Kesting
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top