473,466 Members | 1,465 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Query parameters, Javascript and URL decoding issue

I am having an interesting and rather frustrating issue with the
encoding/decoding of parameters with the ASP.NET runtime. What I am
doing isn't exactly revolutionary so hopefully someone has an answer
for this.

I have a page that accepts a number of parameters. Those parameters may
sometimes include URL reserved characters like spaces and ampersands. I
use a combination of HTML and URL encoding to build links to this page
and everything works fine. No rocket science there. When however I open
a new window via javascript, the runtime seems to act unpredicatbly and
misdecode characters, namely %26, the URL encoded ampersand. For
example, the following URL in this case would work like a charm as part
of an href attribute:

mypage.aspx?t=Home%20%26%20Entertaining&c=Home &p=true

You would get three parameter values: "Home & Entertaining", "Home",
and "true". Writing out the Request.Url in the debugger gives the
following absolute URL:

http://mydomain.com/mypage.aspx?t=Ho...&c=Home&p=true

When that same URL is written into javascript like so:

String.Format("javascript:windowPop('mypage.aspx?t ={0}&c={1}&p=true','',515,600,'no','no','y es')",
Server.UrlEncode(title.Replace("'","\\'")).Replace ("+", "%20"),
Server.UrlEncode(category.Replace("'","\\'")).Repl ace("+", "%20"));

*Note that windowPop is just a wrapper for
window.open(url,name,properties) and isn't important. The extra replace
functions are to escape apostrophes properly for c# and Javascript and
get real space encoding %20 instead of the IE specific plus character
UrlEncoding uses. (Causes the URL not to be found in Mozilla based
browsers)

You get four query parameter values: "Home ", " Entertaining", "Home",
and "true". And writing out the absolute URL in the debugger via "?
Request.Url" gives you the following bad URL:

http://mydomain.com/mypage.aspx?t=Ho...&c=Home&p=true

As you can see the URL encoding for all but the ampersand in the t
parameter is intact.

Anything that can shed light on this behavior would be greatly
apprciated.

Dec 22 '05 #1
0 1987

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

Similar topics

2
by: Tim Simmons | last post by:
I am stumped. I encoded the action = of my form using GET and I can't seem to get the property/value stuff from it using a JavaScript script I got from the web. I want to create a trivia game...
7
by: Julia | last post by:
Hi I am trying to pass an encoded string to a JavaScript the following is the C# code which convert the string STRING_TO_ENCODE to base64 byte bytIn =...
9
by: Mark | last post by:
I've run a few simple tests looking at how query string encoding/decoding gets handled in asp.net, and it seems like the situation is even messier than it was in asp... Can't say I think much of the...
1
by: MattB | last post by:
I'm tightening security on my application by encrypting query strings so someone can't try and guess other valid query string values. This was working well, but I noticed it wasn't working in some...
10
by: mistral | last post by:
I need help implement based64 decoding in javascript: a function to return a script that has been base64 encoded into a string (decoding in client side). For encode, online base64 encoder tool was...
25
by: marcin.rzeznicki | last post by:
Hello everyone I've got a little problem with choosing the best decoding strategy for some nasty problem. I have to deal with very large files wich contain text encoded with various encodings....
6
by: sunil | last post by:
I have a button named Button1, and I wrote an event handler for the OnClick event. protected void Button1_Click(object sender, System.EventArgs e) { this.Response.Redirect("Default.aspx?q=" +...
9
by: Kelii | last post by:
I've been trying to get this piece to work for a few hours, but have given up. I hope someone out there can help, I think the issue is relatively straightforward, but being a novice, I'm stumped....
17
by: NeoAlchemy | last post by:
I am starting to find more web pages that are using a query parameters after the JavaScript file. Example can be found at www.opensourcefood.com. Within the source you'll see: <script...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.