私はMVC4コントローラーにわかりやすい名前を付けることに取り組んでおり、[ActionName="My-Friendly-Name"]
スタイルのようなことをしたいのですが、コントローラー全体に対してです。
そのような属性に関する情報が見つからなかったので、どうすればそれを実行できますか?また、それを処理するために新しいMapRouteを追加する必要がありますか?
編集:
たとえば、次のURLをルーティングしたいと思います。
http://mysite.com/my-reports/Details/5
次のコントローラーにルーティングされます。
[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);
}
}
}