处理 ASP Net Core 路由中的“+”
Handling '+' in ASP Net Core routes
如何在 ASP Net Core 路由中处理“+”?
我有这样定义的路线:
"/Test/{words}/{type:regex(^(AA|BB|CC)$)}/{search2}"
函数参数为string[]个词,字符串类型,string search2
具有不同的 URL:
/Test/word1+word2/AA/blablabla
=> 404
/Test/word1%20word2/AA/blablabla
=> 好的,单词={"word1 word2"}
/Test/word1,word2/AA/blablabla
=> 好的,words={"word1","word2"}
我不明白 404。知道为什么会这样吗?我会用 space.
翻译“+”
您必须编码 space;将 space 编码为 + 是正确的,但仅在查询字符串中;在您必须使用 %20 的路径中。对于 +,您可以使用 %2b。 (HTTP 1.1)
如何在 ASP Net Core 路由中处理“+”? 我有这样定义的路线:
"/Test/{words}/{type:regex(^(AA|BB|CC)$)}/{search2}"
函数参数为string[]个词,字符串类型,string search2
具有不同的 URL:
/Test/word1+word2/AA/blablabla
=> 404/Test/word1%20word2/AA/blablabla
=> 好的,单词={"word1 word2"}/Test/word1,word2/AA/blablabla
=> 好的,words={"word1","word2"}
我不明白 404。知道为什么会这样吗?我会用 space.
翻译“+”您必须编码 space;将 space 编码为 + 是正确的,但仅在查询字符串中;在您必须使用 %20 的路径中。对于 +,您可以使用 %2b。 (HTTP 1.1)