472,111 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,111 software developers and data experts.

Server.UrlDecode from console application

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.com/pagead/ads?client=ca-pub-2969997630540970&random=1089721646950&lmt=10897216 46&format=728x90_as&output=html&channel=7097594418 &url=http%3A%2F%2Fboats.designerz.com%2Fboating-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]));

}
}
}
Nov 18 '05 #1
4 3321
Server is property of the Page class and will not exist in a console app.
try using HttpUtility.UrlDecode

-- bruce (sqlwork.com)
"John Hoge" <jh******@yahoo.com> wrote in message
news:d0**************************@posting.google.c om...
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.com/pagead/ads?client=ca-pub-296999763054
0970&random=1089721646950&lmt=1089721646&format=72 8x90_as&output=html&channe
l=7097594418&url=http%3A%2F%2Fboats.designerz.com% 2Fboating-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]));

}
}
}

Nov 18 '05 #2
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
Nov 18 '05 #3
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.

"John Hoge" <jh******@yahoo.com> wrote in message
news:d0**************************@posting.google.c om...
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

Nov 18 '05 #4
Kevin,

Thanks. It was the reference that was missing.

John
Nov 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by hussein | last post: by
6 posts views Thread by John Grandy | last post: by
62 posts views Thread by Bryan Dickerson | last post: by
6 posts views Thread by Kenan Kilictepe | last post: by
3 posts views Thread by gert | last post: by
2 posts views Thread by Wimpie van Lingen | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.