I have a variable
string rawURL = HttpContext.Current.Request.RawUrl;
How do I read the query string parameters for this url?
I have a variable
string rawURL = HttpContext.Current.Request.RawUrl;
How do I read the query string parameters for this url?
In .NET Core there are multiple ways to access HttpContext like IHttpContextAccessor.
https://docs.microsoft.com/en-us/aspnet/core/fundamentals/http-context?view=aspnetcore-5.0
When you have the Context you can simply use this method:
httpContext.Request.QueryString.Value
Usage:
URL: https://localhost:44335/test?key=123
var key = System.Web.HttpUtility.ParseQueryString(httpContext.Request.QueryString.Value).Get("key");