---
# System prepended metadata

title: mod06
tags: [mvc]

---

```csharp
// operacontroller.cs

// opera/detailsbytitle?title=Rigoletto
// operatitle/Rigoletto
public async  Task< ActionResult> DetailsByTitle(string title)
{
    var opera=await context.Operas.FirstOrDefaultAsync(x => x.Title == title);
    if (opera == null) return HttpNotFound();            
    return View(nameof(Details),opera);
}

// app_start/routeconfig.cs
routes.MapRoute(
 name: "custom",
 url: "operatitle/{title}",
 defaults: new
 {
     controller = "opera",
     action = "DetailsByTitle",
     title = UrlParameter.Optional
 }
);

// opera/index.cshtml
@Html.RouteLink("Custom", "custom", new { title = item.Title })
//=======================
// app_start/routeconfig.cs
public static void RegisterRoutes(RouteCollection routes)
{
    routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    routes.MapMvcAttributeRoutes();

// operacontroller.cs
//[Route("operatitle/{title}",Name ="custom")]
//[Route("operatitle/{title?}", Name = "custom")]
[Route("operatitle/{title=Wozzeck}", Name = "custom")]

public async  Task< ActionResult> DetailsByTitle(string title)

```