1

I have some dynamic querystring parameters that I would like to interact with as an IDictionary<string,string> or similar? How do I do this?

For example. How can I interpret multiple (varying in quantity) variables for a query similar to:

/{area}/{controller}/{action}?alert=primary&msg=Success

Parallel question for asp.net-web-api

BDC
  • 63
  • 1
  • 9

1 Answers1

2

You can use the Query method on the AspNetCore.Http.DefaultHttpRequest to get the parsed query string as a collection of key-value pairs.

public IActionResult Get()
{
    var queryString = this.Request.Query;
}

Additionally, How to read values from the QueryString provides a nice summary of the methods to access and use the IQueryCollection that is created in this approach.

Specifically: ToString() and Inclusion in Method Parameter List.

BDC
  • 63
  • 1
  • 9