Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET MVC nested query parameters

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.

like image 579
Wout Avatar asked May 22 '26 02:05

Wout


1 Answers

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.

like image 85
Ken D Avatar answered May 23 '26 20:05

Ken D