Home All Groups Group Topic Archive Search About

UrlEncode outside ASP. Net???

Author
15 Mar 2006 3:34 PM
AspDotNetDvlpr
Hi,

I'm writing a console application that will be running as a scheduled
application, that basically sends out nag email messages to users of a web
application on a daily basis. It's going great so far, but I ran into a
problem that I can't figure out.

I need to use the UrlEncode method, that is usually available under ASP .Net
using Server.UrlEncode("text") , but when I try and use it in my console
application, after adding a reference to System.Web, and trying to create an
instance of the System.Web.HttpServerUtility class, which contains the
UrlEncode method, I get an error that Overload resolution failed because no
'New' is accessible. Normally, ASP .Net instantiates this as one of it's
intrinsic objects.

Anyone know if there is a way to use this method in a non ASP .Net
application, or if there is a different place with a similar method? I am
stumped at the moment. Thanks!

Author
15 Mar 2006 4:08 PM
Colin Neller
Use System.Web.HttpUtility instead of HttpServerUtility.
Show quoteHide quote
"AspDotNetDvlpr" <aspdotnetdevelo***@hotmail.com> wrote in message
news:%23O6bmXESGHA.1572@tk2msftngp13.phx.gbl...
> Hi,
>
> I'm writing a console application that will be running as a scheduled
> application, that basically sends out nag email messages to users of a web
> application on a daily basis. It's going great so far, but I ran into a
> problem that I can't figure out.
>
> I need to use the UrlEncode method, that is usually available under ASP
> .Net using Server.UrlEncode("text") , but when I try and use it in my
> console application, after adding a reference to System.Web, and trying to
> create an instance of the System.Web.HttpServerUtility class, which
> contains the UrlEncode method, I get an error that Overload resolution
> failed because no 'New' is accessible. Normally, ASP .Net instantiates
> this as one of it's intrinsic objects.
>
> Anyone know if there is a way to use this method in a non ASP .Net
> application, or if there is a different place with a similar method? I am
> stumped at the moment. Thanks!
>
Author
15 Mar 2006 4:50 PM
Herfried K. Wagner [MVP]
"AspDotNetDvlpr" <aspdotnetdevelo***@hotmail.com> schrieb:
> I need to use the UrlEncode method, that is usually available under ASP
> .Net using Server.UrlEncode("text") , but when I try and use it in my
> console application, after adding a reference to System.Web, and trying to
> create an instance of the System.Web.HttpServerUtility class, which
> contains the UrlEncode method, I get an error that Overload resolution
> failed because no 'New' is accessible. Normally, ASP .Net instantiates
> this as one of it's intrinsic objects.
>
> Anyone know if there is a way to use this method in a non ASP .Net
> application, or if there is a different place with a similar method?

Use 'System.Web.HttpUtility.UrlEncode' instead, which is a shared method of
the 'HttpUtility' class.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
15 Mar 2006 5:28 PM
AspDotNetDvlpr
That did the trick guys, thank you much!!


Show quoteHide quote
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
news:uijwfCFSGHA.2156@tk2msftngp13.phx.gbl...
> "AspDotNetDvlpr" <aspdotnetdevelo***@hotmail.com> schrieb:
>> I need to use the UrlEncode method, that is usually available under ASP
>> .Net using Server.UrlEncode("text") , but when I try and use it in my
>> console application, after adding a reference to System.Web, and trying
>> to create an instance of the System.Web.HttpServerUtility class, which
>> contains the UrlEncode method, I get an error that Overload resolution
>> failed because no 'New' is accessible. Normally, ASP .Net instantiates
>> this as one of it's intrinsic objects.
>>
>> Anyone know if there is a way to use this method in a non ASP .Net
>> application, or if there is a different place with a similar method?
>
> Use 'System.Web.HttpUtility.UrlEncode' instead, which is a shared method
> of the 'HttpUtility' class.
>
> --
> M S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
> V B   <URL:http://classicvb.org/petition/>