Accessing the query string in ASP.Net Web Api?

后端 未结 3 1893
礼貌的吻别
礼貌的吻别 2020-12-14 06:09

I\'m using the default template generated by Asp.net Web Api. I\'m working with the Get() Part:

        // GET api/values
    public IEnumerable

        
3条回答
  •  太阳男子
    2020-12-14 07:01

    There is one more way to get query string as shown below when you are using wildcard in route or for dynamic routes.

    string query = ControllerContext.HttpContext.Request.QueryString.Value;
    

    BONUS:)

    string path = ControllerContext.HttpContext.Request.Path.ToUriComponent();
    

提交回复
热议问题