Get url parameters from a string in .NET

前端 未结 13 1866
一个人的身影
一个人的身影 2020-11-22 11:38

I\'ve got a string in .NET which is actually a url. I want an easy way to get the value from a particular parameter.

Normally, I\'d just use Request.Params[

13条回答
  •  广开言路
    2020-11-22 11:48

    You can use the following workaround for it to work with the first parameter too:

    var param1 =
        HttpUtility.ParseQueryString(url.Substring(
            new []{0, url.IndexOf('?')}.Max()
        )).Get("param1");
    

提交回复
热议问题