System.Web.HttpUtility is not available

  • Thread starter Thread starter bullshark
  • Start date Start date
B

bullshark

Hi all.

Just tearing my hair out here. VSN03 XP all latest.

I'm trying to gain use of System.Web.HttpUtility.UrlEncode("string").

The problem is, it isn't there.

I've got:

using System.Web;

I've tried:
System.Web.HttpUtility.UrlEncode("mystring");

Intellisense for System.net only offers:
AspNetHostingPermission
AspNetHostingPermissionAttribute
AspNetHostingPermissionLevel

The 'FindType' utility tells me it's there:
E:\Visual Studio Projects>findtype httputility
class System.Web.HttpUtility
class System.Web.HttpUtility+UrlDecoder

Any attempt to use HttpUtility just gets:
cs(29): The type or namespace name 'HttpUtility' does not exist in the class or namespace 'System.Web' (are you missing an assembly reference?)

My VS.net03 help finds it with F1 and tells me the namespace is System.Web...

Fer Gosh sakes...it's fully qualified AND I've got the using System.Web clause

What is going on?

bullshark
 
Most likely you need to add a reference to it. Right click references in the treeview in solution explorer, click add, find
System.web and add it.
 
Most likely you need to add a reference to it. Right click references in the treeview in solution explorer, click add, find
System.web and add it.

eh? OK? It works?

but why don't I have to do that for
System.IO/Net/Threading etc....

I thought the idea of "using" was to make a reference.

confused but fixed,

bullshark
 
using just saves you typing System.Web.xxx over and over, it doesn't add the reference for you.
 
using just saves you typing System.Web.xxx over and over, it doesn't add the reference for you.

Well Gee whiz. There's a clue.

Maybe the obvious isn't so obvious.

I don't have to add references for everything else in the System,
why was System.Web there in the first place (abbreviated)
Where was
AspNetHostingPermission
AspNetHostingPermissionAttribute
AspNetHostingPermissionLevel
....coming from?
Why was it necessary to add a reference, when
IO/Net/Text/....all are available without?

oh, nevermind. I was under the impression that .net
was a little smarter than java, but I guess not.
Java classpath at least points to everything needed to
use the standard classes, and when the classpath needs
additions, the docs at least say so.
 
When you add a reference to a file it can be called anything, so MyDll could contain any number of namespaces. The System.Web dll
does not have to contain the namespace System.Web and it can contain other namespaces (I assume it does).
oh, nevermind. I was under the impression that .net
was a little smarter than java, but I guess not.

It ain't that complicated, if you need something that's not there you just add a reference.
Java classpath at least points to everything needed to
use the standard classes, and when the classpath needs
additions, the docs at least say so.

If you created a web app from the wizard then you should have that reference. If you created some other sort of app then it makes
sense to need to add it. I would prefer to have a minimal set of reference as standard.
 
Back
Top