.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?

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Carl TawnSystems and Integration DeveloperCommented:
You could always just add a reference to System.Web to your library.
Daniel-BAuthor Commented:
I do have a reference to system.web, I still dont have access to httputility
One option is to reference the System.Web and then use the urlencode method


The other option is this

OWASP: Avoiding Hacker Tricks

Learn to build secure applications from the mindset of the hacker and avoid being exploited.

Carl TawnSystems and Integration DeveloperCommented:
If you have a reference to System.Web, then HttpUtility is there.  How are you trying to access it?
Daniel-BAuthor Commented:
I've tried System.Web.HttpUtility and HttpUtility. Intellisense has no knowledge of it of any kind.
Carl TawnSystems and Integration DeveloperCommented:
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?
Daniel-BAuthor Commented:
Yes, I get:
Carl TawnSystems and Integration DeveloperCommented:
In that case you can't have added a reference to the System.Web assembly. The three items you mention are part of the System.Web namespace, but aren't part of the System.Web assembly itself.

Right-click your project, choose Add Reference, then on the .Net tab scroll down to System.Web, select it then click OK. You should then get access to System.Web.HttpUtility

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Daniel-BAuthor Commented:
Works perfect, thanks.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.