views:

365

answers:

2

(This is a more narrow question)

In my asp.net MVC action, I am looking if the ReturnUrl value is in the URL.

My Url looks like this:

http://localhost:56112/user/login?ReturnUrl=/user/settings

In my action, I am looking if that querystring value exists, and it is returning NULL?? How can this be?

The code:

if(Request.QueryString["ReturnUrl"] != null)
{

}

Tracing through the application, it is just skipping the if statement's body i.e. it is NULL.

How can this be explained?

Update

In the controller that checks if the user has logged in, I have a ActionFilter that looks like:

    public override void OnActionExecuting(ActionExecutingContext filterContext)
    {
        base.OnActionExecuting(filterContext);
        // some stuff
        string loginUrl = FormsAuthentication.LoginUrl + "/user/settings;

         context.Response.Redirect(loginUrl);
    }
+2  A: 

Try debugging the code - you should be able to see in the debugger the entire list of QueryString parameters, so you can see if you miss-spelt it.

Kragen
My querystring collection is empty, but I can see the ?ReturnUrl=/user/settings in the URL.
Blankman
Can you get the Request.RawUrl string and verify that the request does have the full url with query string?
Jace Rhea
The Request.RawUrl doesn't have the querystring. Very strange, the URL in the browser does though??
Blankman
A: 
if(Request.QueryString["ReturnUrl"] != null)
ali62b