3

Ok, this is a bit tricky. I'm implementing a forum in ASP.NET MVC 3. The user wants to post a question, if not logged he gets redirected to the logon page. A returnUrl parameter is passed to the logon page. However, the returnUrl parameter also contains another returnUrl parameter. So the returnUrl parameter passed to the logon page looks like this:

"/forum/NewTopic?boardId=8&returnUrl=%2Fforum%2FBoard%2F8"

But, Request["returnUrl"] looks like this:

"/forum/NewTopic?boardId=8&returnUrl=%2Fforum%2FBoard%2F8,/forum/Board/8"

Notice the appended bit at the end, that shouldn't be there should it? How do I get the proper returnUrl?

However, when having a string returnUrl argument in the controller's action method, this will have the correct returnUrl value.

1 Answer 1

1

I had this problem in MVC3 also, check if the redirecting page is "Login", set a flag, not to add the returnUrl parameter (which is the last appended bit at the end).

This way it does not get populated again.

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

1 Comment

In this case I ended up using a string returnUrl argument in the controller action, because it works correctly even with the nested parameter. I am just curious how to get the same result from the Request. Obviously asp.net mvc knows how to do it, otherwise the action argument wouldn't be correctly set, but until now I haven't found out how. Also I don't understand why the results are different with the 2 different way of getting query parameters.

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.