Link to home
Start Free TrialLog in
Avatar of Daniel-B
Daniel-BFlag for United States of America

asked on

.NET 4.0 urlencode in a class library

I a currently writing a .NET port of some classes originally written in PHP and I need to encode some strings to be safe for use in a URL. The catch is that I am writing this in a class library so I do not have access to system.web.httputility. Everything I have seen online is based around web applications that have access to such features. What I need is a url encoding functions that will function in a class library. Does .NET have such a feature?

Thanks,
Dan
Avatar of Carl Tawn
Carl Tawn
Flag of United Kingdom of Great Britain and Northern Ireland image

You could always just add a reference to System.Web to your library.
Avatar of Daniel-B

ASKER

I do have a reference to system.web, I still dont have access to httputility
If you have a reference to System.Web, then HttpUtility is there.  How are you trying to access it?
I've tried System.Web.HttpUtility and HttpUtility. Intellisense has no knowledge of it of any kind.
That's odd. If you have added a reference to the assembly then it should be recognising it, even if it is a class library.

Are you getting any intellisense response when you access System.Web at all?
Yes, I get:
aspNetHostingPermission
aspNetHostingPermissionAttribute
aspNetHostingPermissionLevel
ASKER CERTIFIED SOLUTION
Avatar of Carl Tawn
Carl Tawn
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Works perfect, thanks.