C
C#2y ago
Pokey

❔ Convert relative URI string to route

Is it possible to take a relative URI string, for example /Api/RetrieveById/1?search=hello and split it into: Controller: Api Action: RetrieveById RouteValues: id = 1, Search = "hello"
3 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pokey
Pokey2y ago
@Divi Thanks Ultimately, I ended up doing this:
string? returnUrl = httpContext.Request.Path.ToUriComponent();
string queryString = httpContext.Request.QueryString.ToUriComponent();

if (!string.IsNullOrWhiteSpace(returnUrl) && !string.IsNullOrWhiteSpace(queryString)) returnUrl += queryString;
string? returnUrl = httpContext.Request.Path.ToUriComponent();
string queryString = httpContext.Request.QueryString.ToUriComponent();

if (!string.IsNullOrWhiteSpace(returnUrl) && !string.IsNullOrWhiteSpace(queryString)) returnUrl += queryString;
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.