473,657 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

UrlEncode outside ASP. Net???

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.UrlEncod e("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.Http ServerUtility 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!
Mar 15 '06 #1
3 4859
Use System.Web.Http Utility instead of HttpServerUtili ty.
--
Colin Neller
http://www.colinneller.com/blog

"AspDotNetDvlpr " <as************ ****@hotmail.co m> wrote in message
news:%2******** ********@tk2msf tngp13.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.UrlEncod e("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.Http ServerUtility 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!

Mar 15 '06 #2
"AspDotNetDvlpr " <as************ ****@hotmail.co m> schrieb:
I need to use the UrlEncode method, that is usually available under ASP
.Net using Server.UrlEncod e("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.Http ServerUtility 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.Htt pUtility.UrlEnc ode' 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/>

Mar 15 '06 #3
That did the trick guys, thank you much!!
"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:ui******** ******@tk2msftn gp13.phx.gbl...
"AspDotNetDvlpr " <as************ ****@hotmail.co m> schrieb:
I need to use the UrlEncode method, that is usually available under ASP
.Net using Server.UrlEncod e("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.Http ServerUtility 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.Htt pUtility.UrlEnc ode' 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/>

Mar 15 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
28407
by: Joshua Beall | last post by:
Hi All, I can see from the manual that the difference between urlencode and rawurlencode is that urlencode translates spaces to '+' characters, whereas rawurlencode translates it into it's hex code. My question is, is there any real world difference between these two functions? Or perhaps another way of asking the question: *why* are there two different functions? In what situation would you need one, and not be able to use the...
3
7640
by: JP SIngh | last post by:
Hi All I have users who upload files using my application using ASPUPLOAD component. My code uploads the file to a network location and once the upload is finish I display the hyperlink using the following code <a href=\myserver\attachments\<%=server.urlencode(rs("FileName"))%> target="_blank" ><%=rs("Filename")%>
1
1850
by: uv2003 | last post by:
Greetings, I've read through some other posts and looked at this class through reflector. All of its contructors are internal, so it cannot be instantiated outside of ASP.NET. This seems unfortunate to me. I'd like to be able to UrlEncode some text completely independent of a web server. Is the only solution to write my own class that does the same thing? Thanks
1
3766
by: yawnmoth | last post by:
Any ideas as to why urlencode(addslashes(chr(0))) returns '%5C0'? It seems like it should return '%00' since that's what urlencode(chr(0)) returns. If not that, I could also see it returning '%5C%00' since that's what urlencode('\\').urlencode(chr(0)) and urlencode('\\'.chr(0)) return. '%5C0', however, confuses me. Even urlencode(chr(0x5C0)) doesn't return '%5C0' - it returns '%C0'.
1
5003
by: Jim | last post by:
Hello, I'm trying to do urllib.urlencode() with unicode correctly, and I wonder if some kind person could set me straight? My understanding is that I am supposed to be able to urlencode anything up to the top half of latin-1 -- decimal 128-255. I can't just send urlencode a unicode character:
4
6732
by: Andreas Klemt | last post by:
Hello, is there a difference between System.Web.HttpUtility.UrlEncode and Server.UrlEncode ?
1
5363
by: Dario Sala | last post by:
Hi, what's the difference about Asp Server.UrlEncode and the Asp.Net Server.UrlEncode ? In asp: Server.UrlEncode("*") = %2A In Asp.Net: Server.UrlEncode("*") = *
4
2580
by: djc | last post by:
1) I just recently used my own function which simply replaces cariage return / line feed characters with <br> tags for a large detail field before showing it via an asp.net page to preserve line breaks for web display. I have since come accross this URLEncode method. Is this something that I should have used for this instead? 2) currently if you were to enter html tags into an input field on my asp.net web page the app will crash... I...
12
4918
by: sleytr | last post by:
Hi, I'm trying to make a gui for a web service. Site using ± character in value of some fields. But I can't encode this character properly. >>> data = {'key':'±'} >>> urllib.urlencode(data) 'key=%C2%B1' but it should be only %B1 not %C2%B1. where is this %C2 coming from?
0
8312
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8827
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8732
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8504
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8606
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6169
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
2732
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1959
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1622
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.