Tom
Tom

Reputation: 1071

ASP.Net MVC 4 Areas and view config

I've read through so many threads on here and none of the solutions seem to be working for me.

I've had troubles creating areas and finding the associated views. I've created a brand new project with nothing else but the default code and created an area called "Assignment". Within the assignment area I have a controller called "AssignmentDetails" with the corresponding view folder.

When I try and view localhost:1234/AssignmentDetails/ I get the error: The view 'Index' or its master was not found or no view engine supports the searched locations

~/Views/AssignmentDetails/Index.aspx
~/Views/AssignmentDetails/Index.ascx
~/Views/Shared/Index.aspx
~/Views/Shared/Index.ascx
~/Views/AssignmentDetails/Index.cshtml
~/Views/AssignmentDetails/Index.vbhtml
~/Views/Shared/Index.cshtml
~/Views/Shared/Index.vbhtml

Globals.asax AreaRegistration.RegisterAllAreas()

    WebApiConfig.Register(GlobalConfiguration.Configuration)
    FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters)
    RouteConfig.RegisterRoutes(RouteTable.Routes)
    BundleConfig.RegisterBundles(BundleTable.Bundles)
    AuthConfig.RegisterAuth()

AssignmentAreaRegistration

        context.MapRoute( _
            "Assignment_default", _
           "Assignment/{controller}/{action}/{id}", _
            New With {.action = "Index", .id = UrlParameter.Optional} _
        )

Upvotes: 0

Views: 1771

Answers (2)

Igor
Igor

Reputation: 15893

View for a controller from area Assignment should be in

~/Areas/Assignment/Views/ControllerName

Upvotes: 1

gideon
gideon

Reputation: 19465

If you have an area called Assignment and AssignmentDetails inside that, you'll find the index at this url:

localhost:1234/Assignment/AssignmentDetails/Index

Upvotes: 0

Related Questions