简体   繁体   English

如何在视图中显示查询字符串

[英]How can i display query string in a view

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我有以下代码在我的视图中显示查询字符串 我使用了ViewContext.RouteData.Values但它只显示id我如何显示 rest 查询,我的 url 看起来像这样http://localhost:XXXX/Products/Product/Edit/4437?ProductName=ASSY 670975 6X5

I have used the following code to get data from url我使用以下代码从 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?我能够显示 4437 或ProductID值,如何在视图中显示ProductNameASSY 670975 6X5

Try this尝试这个

var ProductName = Request.QueryString["ProductName"]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM