Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

.NET 4.0 urlencode in a class library

Posted on 2010-11-16
9
Medium Priority
?
624 Views
Last Modified: 2012-05-10
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
0
Comment
Question by:Daniel-B
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
9 Comments
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 34150217
You could always just add a reference to System.Web to your library.
0
 
LVL 2

Author Comment

by:Daniel-B
ID: 34150226
I do have a reference to system.web, I still dont have access to httputility
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 34150232
One option is to reference the System.Web and then use the urlencode method

http://social.msdn.microsoft.com/forums/en-US/csharpgeneral/thread/12fcaefa-75a9-4fc5-bf06-d5c19322b7b9

The other option is this

http://www.west-wind.com/weblog/posts/617930.aspx
0
Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

 
LVL 52

Expert Comment

by:Carl Tawn
ID: 34150247
If you have a reference to System.Web, then HttpUtility is there.  How are you trying to access it?
0
 
LVL 2

Author Comment

by:Daniel-B
ID: 34150294
I've tried System.Web.HttpUtility and HttpUtility. Intellisense has no knowledge of it of any kind.
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 34150368
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?
0
 
LVL 2

Author Comment

by:Daniel-B
ID: 34150408
Yes, I get:
aspNetHostingPermission
aspNetHostingPermissionAttribute
aspNetHostingPermissionLevel
0
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 2000 total points
ID: 34150435
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
0
 
LVL 2

Author Comment

by:Daniel-B
ID: 34150461
Works perfect, thanks.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

618 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