2
Answers

Generate a valid querystring in MVC

Joy Banerjee

Joy Banerjee

7y
696
1
I am stuck with this problem where I need to send an url in below format -
 
http://localhost:55736/user/viewinfo?userid=569EF26&id=0041
 
I am using the following code -
  1. string url = Url.Action("viewinfo""user"new RouteValueDictionary(new { id = Convert.ToInt32(id), userId = userId }),HttpContext.Request.Url.Scheme,HttpContext.Request.Url.Host);  
This code generates the url like -
 
http://localhost:55736/user/viewinfo/569EF26....
 
Any suggestions how can I improve this??
 
Thanks.. 
Answers (2)
0
Joy Banerjee

Joy Banerjee

NA 74 3.1k 7y
@ravi patel... This did not help .. I used the same technique as it is mentioned in the article you have referred..
0
Ravi Patel

Ravi Patel

279 6.8k 1.4m 7y
Hi,
 
refer this 
 
https://stackoverflow.com/questions/19024208/add-a-query-strings-at-end-of-url-using-routes-in-asp-net-mvc3