Skip to main content
added 124 characters in body
Source Link
M.Ali El-Sayed
  • 1.8k
  • 23
  • 26

in .net core if you want to access querystring in our view use it like

@Context.Request.Query["yourKey"]

if we are in location where @Context is not avilable we can inject it like

@inject Microsoft.AspNetCore.Http.IHttpContextAccessor HttpContextAccessor
@if (HttpContextAccessor.HttpContext.Request.Query.Keys.Contains("yourKey ""yourKey"))
{
      <text>do something </text>
}

also for cookies

HttpContextAccessor.HttpContext.Request.Cookies["DeniedActions"]

in .net core if you want to access querystring in our view use it like

@inject Microsoft.AspNetCore.Http.IHttpContextAccessor HttpContextAccessor
@if (HttpContextAccessor.HttpContext.Request.Query.Keys.Contains("yourKey "))
{
      <text>do something </text>
}

also for cookies

HttpContextAccessor.HttpContext.Request.Cookies["DeniedActions"]

in .net core if you want to access querystring in our view use it like

@Context.Request.Query["yourKey"]

if we are in location where @Context is not avilable we can inject it like

@inject Microsoft.AspNetCore.Http.IHttpContextAccessor HttpContextAccessor
@if (HttpContextAccessor.HttpContext.Request.Query.Keys.Contains("yourKey"))
{
      <text>do something </text>
}

also for cookies

HttpContextAccessor.HttpContext.Request.Cookies["DeniedActions"]
Source Link
M.Ali El-Sayed
  • 1.8k
  • 23
  • 26

in .net core if you want to access querystring in our view use it like

@inject Microsoft.AspNetCore.Http.IHttpContextAccessor HttpContextAccessor
@if (HttpContextAccessor.HttpContext.Request.Query.Keys.Contains("yourKey "))
{
      <text>do something </text>
}

also for cookies

HttpContextAccessor.HttpContext.Request.Cookies["DeniedActions"]