Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Malformed URL by using Page.Request.Url.ToString() - why?

0 views
Skip to first unread message

Axel Dahmen

unread,
Apr 17, 2007, 9:56:00 AM4/17/07
to
Hi,

one of my .aspx pages is called using a URL like:


http://localhost/Test.aspx?returnUrl=http%3a%2f%2flocalhost%2fBackPage.aspx%3fmyParam%3dtest

But when I call Page.Request.Url.ToString() I get:


http://localhost/Test.aspx?returnUrl=http://localhost/BackPage.aspx?myParam=test

Why? How can I obtain the correct URL from the Url object?

TIA,
Axel Dahmen

Axel Dahmen

unread,
Apr 17, 2007, 10:00:04 AM4/17/07
to
... second question is obsolete as OriginalUri And PathAndQuery do the job.
Still why does ToString() return an invalid URI? Is this by intention?

TIA,
Axel Dahmen

Mythran

unread,
Apr 17, 2007, 11:53:33 AM4/17/07
to

"Axel Dahmen" <keent...@newsgroup.nospam> wrote in message
news:B19C17C9-879D-41E8...@microsoft.com...

I believe it's because the URL contains another full URL with QueryString
arguments and the URL parser may be getting confused because it sees = in
the 2nd query string....if you can modify the query string to use URLEncode,
that should help. (Encode the querystring before sending the request ... or
set the URLEncode'ed string for the link you are using....)

HTH,
Mythrna

Walter Wang [MSFT]

unread,
Apr 18, 2007, 2:45:49 AM4/18/07
to
Hi Axel,

The querystring of the URL is encoded using HttpUtility.UrlEncode. When
Uri.ToString() is called, internally it will decode the URL back to its
normal format. Yes it's by design behavior.

Regards,
Walter Wang (waw...@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

0 new messages