Server.UrlDecode from console application

J

John Hoge

Hi,

I need to UrlDecode a string in a simple console application, but I am
having trouble accessing Server.UrlDecode, even though System.Web is
included. The application pulls a text out of a referring URL string
and (eventually) will run a simple report.

Here is an excerpt of my code:

using System;
using System.Web;
using System.Text.RegularExpressions;

namespace Adsense
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{

string test = @"http://pagead2.googlesyndication.co...canoeskayaks.php&color_bg=f5f5f5&color_text=0";
Console.WriteLine (test);
Regex re = new Regex(@"\&url\=([^&]+)&");
Console.WriteLine(Server.UrlDecode(re.Match(test).Groups[1]));

}
}
}
 
B

bruce barker

Server is property of the Page class and will not exist in a console app.
try using HttpUtility.UrlDecode

-- bruce (sqlwork.com)
 
J

John Hoge

Bruce,

No luck with that either. I get

C:\VS\Adsense\Class1.cs(22): The type or namespace name 'HttpUtility'
could not be found (are you missing a using directive or an assembly
reference?)


I do have the using System.Web statement, and the HttpUtility class is
in System.Web, so it should work, right?

Thanks,
John
 
K

Kevin Spencer

Did you add a reference to the System.Web Assembly in your project
references?

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top