Horje
route( controller ) c# Code Example
route( controller ) c#
By using the new [controller] token in your attribute routes you can ensure 
that the controller name in the route, is kept in sync with the name of the 
controller class. In the example below, [controller] will always be expanded 
to the name of the controller regardless of any future refactorings – in this
case it will be Hello.

[Route("[controller]")] // there are placeholders for common patterns 
                           as [area], [controller], [action], etc.

[HttpGet("")] // empty is valid. url.com/prefix

[Route("")] // empty is valid. url.com/

[HttpGet("/otherprefix/name")] // starting with / won't use the route prefix

[HttpGet("name/{id}")]
public IActionResult Index(int id){ ... // id will bind from route param.

[HttpGet("{id:int:required}")] // you can add some simple matching rules too.




Csharp

Related
C# trim trailing zero Code Example C# trim trailing zero Code Example
c# write to output window Code Example c# write to output window Code Example
print a file from C# Code Example print a file from C# Code Example
function c# Code Example function c# Code Example
instantiate prefab unity Code Example instantiate prefab unity Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
13