How to get Request Querystring values?

后端 未结 3 580
鱼传尺愫
鱼传尺愫 2020-12-31 09:30

My api client code sends an authentication token in the querystring like:

www.example.com/api/user/get/123?auth_token=ABC123

I\'m using Mvc

3条回答
  •  自闭症患者
    2020-12-31 10:16

    Another way to do it, similar to Badri's:

    string qsValue = string.Empty;
    if (Request.QueryString.HasValue)
    {
       NameValueCollection queryStringNameValues = HttpUtility.ParseQueryString(Request.QueryString.Value);
       qsValue = queryStringNameValues.Get("auth_token");
    }
    

提交回复
热议问题