1

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

1
  • method name Page_Load hardly correlates well to tag mvc :) Commented May 29, 2012 at 14:33

4 Answers 4

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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.

1 Comment

This is null and is my issue I'm posting about. If this worked I wouldn't have an issue.
0

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

Comments

0

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

1 Comment

This is null and is my issue I'm posting about. If this worked I wouldn't have an issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.