How can i display query string in a view

2020-05-27 asp.net asp.net-mvc asp.net-core query-string querystringparameter

I have the following code to display query string in my view I used ViewContext.RouteData.Values but it only display id how can i display the rest query, my url looks like this http://localhost:XXXX/Products/Product/Edit/4437?ProductName=ASSY 670975 6X5

I have used the following code to get data from url

var ProductID = ViewContext.RouteData.Values["id"];
var ProductName= ViewContext.RouteData.Values["ProductName"];

I'm able to display 4437 or the ProductID value, How can i display ProductName or ASSY 670975 6X5 in a view?

Answers

Try this

var ProductName = Request.QueryString["ProductName"]

Related