Reputation: 1339
I have been googling for a few hours. But still not able to get the answer. I need to get a query string parameter in a razor view.
Here is my code:
if @(Request.Query["value"]=="P"){
<a href="@Url.Action("Index", "Staff",new { status = "A"})"><strong>Active (@ViewData["activeCount"]) </strong></a>
<a href="@Url.Action("Index", "Staff",new { status = "I" })">In-Active (@ViewData["inActiveCount"])</a>
<a href="@Url.Action("Index", "Staff",new { status = "D" })">Delete (@ViewData["deleteCount"])</a>
}else{
<a href="@Url.Action("Index", "Staff",new { status = "A"})">Active (@ViewData["activeCount"])</a>
<a href="@Url.Action("Index", "Staff",new { status = "I" })"><strong>In-Active (@ViewData["inActiveCount"])<strong></a>
<a href="@Url.Action("Index", "Staff",new { status = "D" })">Delete (@ViewData["deleteCount"])</a>
}
But i get the error "The name 'Request' does not exist in the current context"
The screenshot
Anyone got solution? Thanks
Upvotes: 14
Views: 16541
Reputation: 1339
Yes you finally can. The answer is Context.Request.Query ["value"]
Upvotes: 1
Reputation: 841
Use Context.Request.Query["value"]
rather than Request.Query["value"]
Upvotes: 45