[HttpGet("Verification?g={g}")]
public IActionResult Verify (string g)
{
return View("Verification.cshtml");
}
I wrote the routing like above but then there was an error "Literal sections cannot contain the '?' character."
how to write controller routing to create URL like http://localhost/VerificationController/Verify/Verification?g={guid}
Please help me to solve this, thank you in advance.
When any defined parameter not referenced as part of the route rule the MVC parser trying to interpret it as query parameter. Therefore, to get URL like
https://localhost/VerificationController/Verify/Verification?g=some_value
you can use:
[HttpGet("{controller}/Verify/Verification")]
public IActionResult Verify(string g)
{
return View("Verification.cshtml");
}
Or, if you controller class is prefixed with [Route("[controller]")]
you can use:
[HttpGet("Verify/Verification")]
public IActionResult Verify(string g)
{
return View("Verification.cshtml");
}