Skip to content

Instantly share code, notes, and snippets.

@manoj-choudhari-git
Last active May 28, 2021 21:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save manoj-choudhari-git/5851d23dbbd96fce9899c72fff26c092 to your computer and use it in GitHub Desktop.
Save manoj-choudhari-git/5851d23dbbd96fce9899c72fff26c092 to your computer and use it in GitHub Desktop.
.NET Core Web Application - Use of Route attribute
// Route attribute can also be placed on controller
public class SampleController : Controller
{
[Route("/")]
[Route("Sample")]
[Route("Sample/Index")]
[Route("Sample/Index/{id?}")]
public ActionResult Index()
{
return View();
}
[Route("Sample/Details")]
[Route("Sample/Details/{id?}")]
public ActionResult Details(int id)
{
return View();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment