访问查询字符串参数,在ASP.NET中不包含任何值 [英] Access Query string parameters with no values in ASP.NET

查看:56
本文介绍了访问查询字符串参数,在ASP.NET中不包含任何值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试设置一个具有两种行为的页面.我用URL分隔它们:一种行为是通过/some-controller/some-action访问的,另一种行为是通过/some-controller/some-action?customize的.

I am trying to set up a page that has two behaviors. I'm separating them by URL: One behavior is accessed via /some-controller/some-action, the other is via /some-controller/some-action?customize.

它看起来不像Request.QueryString对象,但是当我访问第二个URL时...我的意思是,键集合中有一个元素,但是它是null而不是'customize' .任何人对此都有任何想法或如何启用它.我想避免不惜一切代价手动解析查询字符串:).

It doesn't look like the Request.QueryString object contains anything, though, when I visit the second URL...I mean, the keys collection has one element in it, but it's null, not 'customize'. Anyone have any ideas about this or how to enable this. I'd like to avoid manually parsing the query string at all costs :).

推荐答案

ASP.NET不支持确定没有值的查询字符串参数的存在,因为Request.QueryString["customize"]Request.QueryString["foo"]都是null.您要么必须自己解析它,要么指定一个值,例如?customize=1

ASP.NET does not support determining the presence of query string parameters without values since Request.QueryString["customize"] and Request.QueryString["foo"] are both null. You'll either have to parse it yourself or specify a value e.g. ?customize=1

这篇关于访问查询字符串参数,在ASP.NET中不包含任何值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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