August 2018
Intermediate to advanced
298 pages
5h 33m
English
Scenario
By using IActionConstraint and IActionConstraintFactory interfaces we can add custom constraints. Create an attribute that implements IActionConstraintFactory and returns an IActionConstraint. Use it and modify the below code so that for the Accept: text/html header, Index2_HTML is called but for Accept: application/json, Index2_Json is called. You may use Fiddler to send the requests.
[Route("Home")]public class HomeController : Controller{ // GET: /<controller>/ [HttpGet()] public IActionResult Index() { return Content("Index action method"); } [HttpGet("Index2")] public IActionResult Index2_HTML() { return Content("HTML response returns"); } [HttpGet("Index2")] ...Read now
Unlock full access