Trying to create default ASP.NET MVC Route with AttributeRouting

I just started using AttributeRouting with my ASP.NET MVC3 application. I started with -no controllers in general. (New empty MVC3 application)

Then I made an area. (called: Documentation)

Then I added a controller (called: DocumentationController)

Then I did it.

[RouteArea("Documentation")]
public class DocumentationController : Controller
{
    [GET("Index")]
    public ActionResult Index()
    {
        return View();
    }
}

And the following route works: /documentation/index

but how can I do these two routes, work?

1 - /<- (default route / no specific route specified) 2 - /documentation<- no 'index' subroutine section added.

Can this be done with AttributeRouting ?

UPDATE:

, ASP.NET MVC3 .. , , AttributeRouting.

+5
1

, , "/" "/documentation" DocumentationController.Index, ? , :

[RouteArea("Documentation")]
public class DocumentationController : Controller
{
    [GET("Index", Order = 1)] // will handle "/documentation/index"
    [GET("")] // will handle "/documentation"
    [GET("", IsAbsoluteUrl = true)] // will handle "/"
    public ActionResult Index()
    {
        return View();
    }
}

:

  • GET ( "" ) Order = 1, . - , , Order.
  • , . .
  • IsAbsoluteUrl URL, RouteArea RoutePrefix. , root.

, . , , , .

+9

All Articles