且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用Request.QueryString从url获取第二个字符串

更新时间:2023-02-06 19:15:01

要将多个参数放入查询字符串,请使用&分开它们:

例如

To put multiple parameters into a query string, use & to separate them:

For example

example.com/default.asps?animal=tiger&fruit=apple



要提取它们,请使用



To extract them, use

string myAnimal = Request.QueryString("animal")
string myFruit = Request.QueryString("fruit")


实际上,您可以通过两种方式做到这一点.

1.您可以使用许多变量构建链接,例如:
www.whatever.com/default.aspx? category1 = A& category2 = B& category3 = C

2.您可以在一个类别名称中编写您的个人逻辑:
www.whatever.com/default.aspx? category = A | B | C
然后,当您获得类别值时,只需对其进行解析即可.

希望对您有所帮助.
Actually here are two ways you can do that.

1. You can build a link with many variables like:
www.whatever.com/default.aspx?category1=A&category2=B&category3=C and so on

2. You can program your personal logic in one category name:
www.whatever.com/default.aspx?category=A|B|C
and after when you get a category value just parse it.

I hope it helps.