Atrybut ControllerName C # MVC 4
Pracuję nad dostarczeniem przyjaznych nazw dla moich kontrolerów MVC 4 i chcę zrobić coś takiego[ActionName="My-Friendly-Name"]
styl, ale dla całego kontrolera.
Nie mogłem znaleźć żadnych informacji o takim atrybucie, więc jak mam to zrobić? Czy będę musiał dodać nową MapRoute, aby ją obsłużyć?
EDYTOWAĆ:
Na przykład chcę skierować następujący adres URL:
http://mysite.com/my-reports/Details/5
być kierowane do następującego kontrolera:
[ControllerClass="my-reports"] // This attribute is made up. I'd like to know how to make this functionality
public class ReportsController : Controller
{
//
// GET: /Reports/
public ActionResult Index()
{
return View();
}
public ViewResult Details(int id)
{
Report report = db.Reports.Single(g => g.Id == id);
return View(report);
}
public ActionResult Create()
{
return View();
}
[HttpPost]
public ActionResult Create(Report item)
{
try
{
if (ModelState.IsValid)
{
item.Id = Guid.NewGuid();
_context.Reports.AddObject(item);
_context.SaveChanges();
return RedirectToAction("Index");
}
return View(item);
}
catch (Exception)
{
return View(item);
}
}
}