How to create route like site.net/query
?
Attention, not
site.net/?q=querystring
What I want is:
site.net/querystring
I tried something like this, but this don't work
[Route("")]
class MyController : Controller
{
[HttpGet]
public string Get()
{
return Request.QueryString.ToString();
}
Just put that path in the routing string:
[HttpGet("/Something/[action]/{q}")]
public string Get(string q)
{
return q;
}
When you access this link: localhost/Something/Get/mynicestring
mynicestring
will be shown
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.