简体   繁体   中英

Web API and Attribute routing

I am new in web api and attribute routing. just read a article from here. http://www.binaryintellect.net/articles/a2bf5c05-18a6-44b3-9f73-5896b40f0dff.aspx

see their attribute routing for web api action

[Route("api/[controller]/Logout")]
[HttpPost]
public IActionResult Logout()
{
    HttpContext.SignOutAsync(
CookieAuthenticationDefaults.AuthenticationScheme);
    return new ObjectResult("Success");
}

I have very basic questions. this attribute routing is ok [Route("api/[controller]/Logout")] controller name should be wrapped in {} or [ ] ?

Is it mandatory that when work with token then we need to work with identity?

can't we generate token if we work with form authentication ?

I am very beginner developer. so please help me with knowledge.

Thanks

For convenience, attribute routes support token replacement by enclosing a token in square-braces ([, ]). The tokens [action], [area], and [controller] will be replaced with the values of the action name, area name, and controller name from the action where the route is defined.

The [controller] token is replaced with the name of the controller where the action is defined in.

See Token replacement in route templates to learn more about that.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM