Solved

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

Posted on 2007-12-02
3
219 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 125 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

752 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