2021-06-16 14:27:02 +10:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Web;
|
|
|
|
|
using System.Web.Mvc;
|
|
|
|
|
|
|
|
|
|
namespace AttributeRoutingDemoInMVC.Controllers
|
|
|
|
|
{
|
|
|
|
|
public class HomeController : Controller
|
|
|
|
|
{
|
2021-06-16 15:19:24 +10:00
|
|
|
|
// Optional URI Parameter
|
|
|
|
|
// URL: /MVCTest/
|
|
|
|
|
// URL: /MVCTest/Pranaya
|
|
|
|
|
[Route("MVCTest/{studentName ?}")]
|
|
|
|
|
public ActionResult MVC(string studentName)
|
2021-06-16 14:27:02 +10:00
|
|
|
|
{
|
2021-06-16 15:19:24 +10:00
|
|
|
|
ViewBag.Message = "Welcome to ASP.NET MVC!";
|
2021-06-16 14:27:02 +10:00
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-16 15:19:24 +10:00
|
|
|
|
// Optional URI Parameter with default value
|
|
|
|
|
// URL: /WEBAPITest/
|
|
|
|
|
// URL: /WEBAPITest/Pranaya
|
|
|
|
|
[Route("WEBAPITest/{studentName = Pranaya}")]
|
|
|
|
|
public ActionResult WEBAPI(string studentName)
|
2021-06-16 14:27:02 +10:00
|
|
|
|
{
|
2021-06-16 15:19:24 +10:00
|
|
|
|
ViewBag.Message = "Welcome to ASP.NET WEB API!";
|
2021-06-16 14:27:02 +10:00
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|