Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Where is UrlEncode method if I need to call it from a business object class?

Posted on 2007-12-02
3
Medium Priority
?
226 Views
Last Modified: 2012-06-27
I have an ASP.NET/C# application. In a method in one of the business object classes, I need to make an HttpWebRequest to a website that returns an XML response. I need to URL-encode the request, but the System.Web namespace in an ".cs" business object class does not include the needed HttpUtility class that it does in the System.Web namespace if called directly from the ".aspx.cs" code-behind. I could hack a work-around to pass the string value back to the .aspx.cs page and then pass the url-encoded value back to the .cs class, but that doesn't seem very elegant, and I don't think that I should have to, since I may need to use this method from other places.

So, my question is, where do I find a UrlEncode method that I can use?
0
Comment
Question by:DanielBorson
[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
  • 2
3 Comments
 
LVL 29

Accepted Solution

by:
Göran Andersson earned 500 total points
ID: 20392646
Include the name using using:

using System.Web;

or specify the full namespace:

... = System.Web.HttpUtility.UrlEncode(...)

If you don't have a reference to the system.web.dll, you need to add it. Right click on references in the project in the solution explorer, and select Add Reference. Add the System.Web library.
0
 

Author Comment

by:DanielBorson
ID: 20392899
That was it. I was seeing a "System.Web", so I thought I had that reference, but it only had three classes in it, so I'm not sure what that was, but it wasn't the System.Web I needed. Adding the reference to the project was what it needed. Thanks.
0
 
LVL 29

Expert Comment

by:Göran Andersson
ID: 20393043
There are some classes in the System.Web namespace in the mscorlib.dll, so they are always there. Although most libraries have their own namespace, there is nothing that keeps a namespace from being spread across several libraries.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

688 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