473,888 Members | 1,564 Online
Bytes | Software Development & Data Engineering Community
+ 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=H ome%20%26%20Ent ertaining&c =Home&p=tru e

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


When that same URL is written into javascript like so:

String.Format(" javascript:wind owPop('mypage.a spx?t={0}&c ={1}&p=true ','',515,600,'n o','no','yes')" ,
Server.UrlEncod e(title.Replace ("'","\\'")).Re place("+", "%20"),
Server.UrlEncod e(category.Repl ace("'","\\'")) .Replace("+", "%20"));

*Note that windowPop is just a wrapper for
window.open(url ,name,propertie s) 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

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:


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

Dec 22 '05 #1
0 2029

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

Similar topics

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 where the user gets 1 question at a time and it keeps scoring until the end and gives a summary and I want to do it only in JavaScript (no ASP, PHP, JSP, etc). I tried submitting the quiz page to itself using a query string to keep track of...
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 = System.Text.UnicodeEncoding.Unicode.GetBytes(STRING_TO_ENCODE); string result=System.Convert.ToBase64String
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 "improvements", but maybe someone here can point me in the right direction... First, it looks like asp.net will automatically read and recognize query strings encoded in utf8 and 16-bit unicode, only the latter is some mutant, non-standard...
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 cases today. Looking a little deeper, it seems that when encrypted one value had a + in it. When this was picked up at the receiving page, I see the + turns into a space, which then throws off the decryption. Is a + an illegal character for a...
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 used. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>JavaScript Base64 Decoder</title> <script type="text/javascript">
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. Their length makes loading contents of file into memory in single run inappropriate. I solved this problem by implementing memory mapping using P/Invoke and I load contents of file in chunks. Since files' contents are in different encodings what I...
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=" + this.TextBox1.Text+ " "); } The TextBox1 is a text box that takes user input. I get the text box content by extracting the query parameters as
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. Below you will find the code I've written and the error that results. I'm hoping that someone can give me some direction as to what syntax or parameter is missing from the code that is expected by VBA. Overview: I'm trying to copy calculated...
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 src="/shared/scripts/common.js?revision=1.6" type="text/javascript">. I am trying to see if there is any big deal to this or a best practice that is starting to creep up in the JavaScript community. If this is used only as a way to distinguish what...
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
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,...
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...
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...
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,...
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...
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.