In my project (ASP.NET Webform), I have a hyperlink on a view. When I click on this link, it will direct me to another view on my website. Here is the link on my view.
<a href="https://mytest.com/mysite/mypage.aspx?returnURL=https://mytest.com/mysite/DynamicView.aspx?view_code=_SAA1DKIVJ&module_code=R&selected_row=0258B963A2">View My Ticket</a>
Now, I click the above link, and I catch the request at the Application_BeginRequest event in the Global.asax page. Please note the different values between Request.QueryString and Request.QueryString(“returnURL”).
Request.QueryString returnURL=https%3a%2f%2fmytest.com%2fmysite%2fDynamicView.aspx%3fview_code%3d_SAA1DKIVJ&module_code=R&selected_row=0258B963A2
Request.QueryString(“returnURL”)
https://mytest.com/mysite/DynamicView.aspx?view_code=_SAA1DKIVJ
As you can see, Request.QueryString(“returnURL”) is missing two parameters module_code and selected_row
I have no idea why this weird thing occurs. I am expecting Request.QueryString(“returnURL”) should have the same value as Request.QueryString.
I would appreciate your help in this matter!
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
You need to encode the parameters properly. There are two ? in the url, that is not allowed.
<a href="https://mytest.com/mysite/mypage.aspx?returnURL=<%=
HttpUtility.UrlEncode("https://mytest.com/mysite/DynamicView.aspx?view_code=_SAA1DKIVJ&module_code=R&selected_row=0258B963A2")
%>">View My Ticket</a>
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0