I want to parse data from a URL string at ASP.NET MVC 5. Here are the important lines.
Index.cshtml
:
@Html.ActionLink(Name, ActionName, new { id = 6, status = 1 })
Browers Line
http://localhost/somthing/6?status=1
create.cshtml
:
@ViewContext.RouteData.Values["id"]
@ViewContext.RouteData.Values["status"]
The values from "id" is "6" but the value from "status" is null.
What I have to do get the "1" from the URL string?
CodePudding user response:
There are a few possibilities:
Request.QueryString["status"];
Request.Params["status"];
In .Net Core it seems like you have to use:
Context.Request.Query["status"];