如何在ASP.Net MVC视图中访问querystring? [英] how to access querystring in ASP.Net MVC View?

查看:76
本文介绍了如何在ASP.Net MVC视图中访问querystring?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在视图中访问querystring值?

推荐答案

在视图中访问查询参数不是一个好的设计.该视图应使用控制器提供的模型.因此,控制器读取查询参数并将其传递给视图.如果您想忽略此规则,则可以始终在您的视图中执行以下操作:

It is not a good design to access query parameters in a view. The view should use the model provided by the controller. So the controller reads query parameters and passes them to the view. If you want to ignore this rule you could always do this in your view:

<%= Request["SomeParameter"] %>

但我强烈劝阻您不要这样做.

But I would strongly discourage you from doing so.

这篇关于如何在ASP.Net MVC视图中访问querystring?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆