Click here to get back home

ampersand in urls when using xhtml 1.0 strict

 HomeNewsGroups | Search | About
 comp.infosystems.www.authoring.html    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
ampersand in urls when using xhtml 1.0 strict mark4asp 12-17-2007
Posted by mark4asp on December 17, 2007, 1:13 pm
Please log in for more thread options
Martin Honnen wrote:

> mark4asp wrote:
>
> > If I have, say:
> >         <a href="../page1.aspx?a=1&amp;b=gonow">Go Now</a>
> > in my html, on clicking the link, will FF give :
> >         blah blah/page1.aspx?a=1&b=gonow
> > in the address bar?
> >
> > It's not doing that for me. It gives
> >         blah blah/page1.aspx?a=1&amp;b=gonow
>
> Can you post a URL where that happens?

I'm sorry. It is happening right now on my local web-server. This is an
asp.net 2.0 application I am running over microsoft's Cassini server
[the developer's 'baby' web-server - not IIS]. Even if it were live,
it's a subscription only site.

It's a puzzle alright. I tell asp.net to write an &amp; in the code
behind for the gridview (OnRowDataBound event). It gives me a &
But if I tell it to write an &amp; for the asp.net Repeater I get the
&amp; in the html with no problems. [ILLOGICAL]. The asp.net controls
shoudl be consistent!

FF consistently puts the &amp; in the address bar. [WRONG]

The validation software tells me the page with a '&' in the hrefs is OK
[WRONG]

So there are several wrong things going on here all at once.


I guess I should continue this in the asp.net forum.




--


Posted by Harlan Messinger on December 17, 2007, 1:20 pm
Please log in for more thread options
mark4asp wrote:
> Martin Honnen wrote:
>
>> mark4asp wrote:
>>
>>> If I have, say:
>>>         <a href="../page1.aspx?a=1&amp;b=gonow">Go Now</a>
>>> in my html, on clicking the link, will FF give :
>>>         blah blah/page1.aspx?a=1&b=gonow
>>> in the address bar?
>>>
>>> It's not doing that for me. It gives
>>>         blah blah/page1.aspx?a=1&amp;b=gonow
>> Can you post a URL where that happens?
>
> I'm sorry. It is happening right now on my local web-server. This is an
> asp.net 2.0 application I am running over microsoft's Cassini server
> [the developer's 'baby' web-server - not IIS]. Even if it were live,
> it's a subscription only site.
>
> It's a puzzle alright. I tell asp.net to write an &amp; in the code
> behind for the gridview (OnRowDataBound event). It gives me a &
> But if I tell it to write an &amp; for the asp.net Repeater I get the
> &amp; in the html with no problems. [ILLOGICAL]. The asp.net controls
> shoudl be consistent!

Wait a minute--it just hit me. I'm not that familiar with ASP.NET but I
know Visual Studio second-guesses the developer in certain ways. Have
you checked View Source in Firefox to see what's in the source code
being received by the browser? I suspect that when you put a link
control on an ASP page, it assumes you're entering the actual, unencoded
URL and *encodes it for you*. So if you're entering &amp;, it's
converting it to &amp;amp;. Check it and see.

Posted by Andreas Prilop on December 17, 2007, 12:59 pm
Please log in for more thread options
On Mon, 17 Dec 2007, mark4asp wrote:

> If I have, say:
>         <a href="../page1.aspx?a=1&amp;b=gonow">Go Now</a>

Give us the address (URL)!

Meanwhile take this
http://www.unics.uni-hannover.de/nhtcapri/ampersand.html

Posted by Harlan Messinger on December 17, 2007, 1:12 pm
Please log in for more thread options
mark4asp wrote:
> Harlan Messinger wrote:
>
>> mark4asp wrote:
>>> When I write a url in xhtml, with an unencoded ampersand, like this:
>>>
>>> http://localhost:2063/Client/ViewReport.aspx?Ref=58&Type=SUMMARY
>>>
>>> the xhtml sytax checker correctly indicates an error, telling me
>>> that it should be:
>>>
>>> http://localhost:2063/Client/ViewReport.aspx?Ref=58&amp;Type=SUMMARY
>>>
>>> see: <http://www.htmlhelp.com/tools/validator/problems.html#amp>
>>>
>>> However the last sentence there ends:
>>>
>>>         "the browser translates "&amp;" to "&" so the Web server would only
>>> see "&" and not "&amp;" in the query string of the request."
>>>
>>> My web server is clearly seeing &amp; and the browser (FF 1.0.0.11)
>>> is also showing &amp; in the url.
>>>
>>> I am using:
>>>         <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
>>> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
>>>
>>> with no xml prefix because, as we all know, IE6 breaks when the xml
>>> prefix is present.
>>>
>>> What is the cause and solution of this problem.
>>>
>>> I am using FF 1.0.0.11, via a local asp.net 2.0 site through the
>>> mini webserver (Cassini) on WinXP SP2 with all latest o/s updates
>>> installed (apart from IE7, I am using IE6 on this PC).
>> You're using 1.0.0.11? The bug is that it's practically the very
>> first version released and it was superseded by 1.0.1 within a couple
>> of months, by 1.5 over two years ago, and by 2.0 over a year ago.
>> Based on usage of the high-traffic site I'm involved with, virtually
>> no one is using Firefox 1.x any more (probably because Firefox
>> prompts you to update it), and you certainly shouldn't be doing
>> anything with a version that has been outdated over ten times as long
>> as the product had existed when the version was replaced.
>
> Apologies, a typo. I am using FF 2.0.0.11
>
>>> Do I have to apply a url decode algorithm when the web page loads?
>>> That is far from ideal because the problem here is that the browser
>>> is not showing the decoded url.
>>>
>>> Is this a bug in FF?
>> There is no problem with this whatsoever in Firefox 2, I can tell you
>> that. Use &amp; in your links and images and so forth and it'll work.
>
> So exactly what should happen.
>
> If I have, say:
>         <a href="../page1.aspx?a=1&amp;b=gonow">Go Now</a>
> in my html, on clicking the link, will FF give :
>         blah blah/page1.aspx?a=1&b=gonow
> in the address bar?
>
> It's not doing that for me. It gives
>         blah blah/page1.aspx?a=1&amp;b=gonow

I don't see how that's happening. I just built a page called
amp_in_url.html as follows:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Amp in URL</title>
</head>
<body>
<h1>Amp in URL</h1>
<p><a href="amp_in_url.html?a=1&amp;b=gonow">Go Now</a></p>
</body>
</html>

When I hover the cursor over the link Firefox's status bar reads

http://www.[mycompany].com/amp_in_url.html?a=1&b=gonow

When I click the link, IIS's log entry includes:

80 GET /amp_in_url.html a=1&b=gonow 200

(port 80, method GET, path /amp_in_url.html, querystring a=1&b=gonow,
status 200).

The result is the same if I switch to XHTML.




>
> Which the server reads and tells me that it can't get my querystrings.
> I suppose I can url decode this at the server end to fix it.
>
>

Posted by mark4asp on December 17, 2007, 9:06 am
Please log in for more thread options
mark4asp wrote:

> When I write a url in xhtml, with an unencoded ampersand, like this:
>
> http://localhost:2063/Client/ViewReport.aspx?Ref=58&Type=SUMMARY
>
> the xhtml sytax checker correctly indicates an error, telling me that
> it should be:
>
> http://localhost:2063/Client/ViewReport.aspx?Ref=58&amp;Type=SUMMARY
>
> see: <http://www.htmlhelp.com/tools/validator/problems.html#amp>
>
> However the last sentence there ends:
>
>         "the browser translates "&amp;" to "&" so the Web server would only
> see "&" and not "&amp;" in the query string of the request."
>
> My web server is clearly seeing &amp; and the browser (FF 1.0.0.11) is
> also showing &amp; in the url.
>
> I am using:
>         <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
>
> with no xml prefix because, as we all know, IE6 breaks when the xml
> prefix is present.
>
> What is the cause and solution of this problem.
>
> I am using FF 1.0.0.11, via a local asp.net 2.0 site through the mini
> webserver (Cassini) on WinXP SP2 with all latest o/s updates installed
> (apart from IE7, I am using IE6 on this PC).
>
> Do I have to apply a url decode algorithm when the web page loads?
> That is far from ideal because the problem here is that the browser is
> not showing the decoded url.
>
> Is this a bug in FF?
>
> Finally is there a DOCTYPE I can use to force all the 5 major
> browsers: IE6, IE7, FF, Opera, Safari to all render in strict mode
> when displaying xhtml?

The immediate problem is now fixed. Somehow the page with the urls was
missing a Content-Type header:
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

After including this header I was able to remove the encoded
ampersands, [ &amp; ], to replace them with just a &. The xhtml
syntax checker no longer indicated errors here and the page navigation
now works.


--


Similar ThreadsPosted
utf-8 and xhtml 1.0 strict October 28, 2004, 7:26 am
xhtml vs html 4 strict May 21, 2005, 5:23 pm
Strict XHTML and div question July 14, 2005, 7:07 pm
XHTML 1.0 Strict and the Apostrophe February 15, 2008, 11:12 am
What to use intead of taget_new in XHTML/Strict July 19, 2004, 7:41 am
image maps + xhtml strict October 23, 2004, 9:16 pm
Valid XHTML strict messed up in IE Mac December 20, 2004, 7:13 pm
XHTML 1.0 Strict validation problem November 11, 2005, 10:30 am
HTML 4.01 strict / transitional vs. XHTML 1.0 September 18, 2005, 3:10 pm
Validation: XHTML Transitional vs. HTLM 4.01 Strict July 23, 2004, 6:10 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap