可以请求的查询字符串从访问的HtmlHelper [英] can request querystring be accessed from htmlhelper

查看:114
本文介绍了可以请求的查询字符串从访问的HtmlHelper的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可以查询字符串中的HtmlHelper扩展方法进行访问。我们需要渲染不同,具体取决于在请求查询字符串。

Hi Can query string be accessed in HTMLHelper extension methods. We need to render differently depending on the querystring in the request.

推荐答案

是,通过目前的情况下,这是HTML辅助属性。

Yes, through the current context, which is a property on HTML Helper.

public static string DoThis(this HtmlHelper helper)
{
   string qs = helper.ViewContext.HttpContext.Request.QueryString.Get("val");
   //do something on it
}

这篇关于可以请求的查询字符串从访问的HtmlHelper的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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