Buchannon
Buchannon

Reputation: 1691

.NET application stripping query string parameters from Request in Default.aspx.cs

I am having a hard time figuring out why the request part of my URL is not showing up correctly in the Page_Load method of Default.aspx.cs in my application.

If my URL is something like this:

http://localhost:3161/SignOn?ReturnUrl=%2fReturnMeHere

When I debug, I'd expect there to be query string parameters in my Request object:

public void Page_Load(object sender, System.EventArgs e)
{
    string originalPath = Request.Path;
}

However, none show up. I'm guessing these are being stripped out somewhere but I'm not sure what else would be doing this in the pipeline.

*Edit, a screenshot from a local URL debugging "http://localhost:3161/SignOn?ReturnUrl=/ThisIsDisappearing" enter image description here

Upvotes: 1

Views: 850

Answers (4)

LukeHennerley
LukeHennerley

Reputation: 6444

The path to a page will always be www.url.co.uk.

The raw path will be the full path without any formatting or stripping.

Query strings are extensions to the path, not part of the path so therefore they wont be included.

As stated above, refering the the raw URL not the path of the page will bring back the full string.

Upvotes: 1

the_joric
the_joric

Reputation: 12261

Request.Params["ReturnUrl"] should return the value of ReturnUrl parameter

Upvotes: 0

Jeff Watkins
Jeff Watkins

Reputation: 6357

Request.Path strips off the parameters Request.RawUrl shows the whole URL, Request.Query is just the query string.

Upvotes: 0

Sachin Kainth
Sachin Kainth

Reputation: 46760

Look at Request.QueryString that is where query string parameters are stored.

Request.Path would only give you "http://localhost:3161/SignOn" as far as I can remember.

Upvotes: 0

Related Questions