Question

I've read every thread/question on this topic but never found an answer.

In my MVC4 project I've just added a new area called "Admin". I see that AdminAreaRegistration.vb has been generated by default:

Public Class AdminAreaRegistration
    Inherits AreaRegistration

    Public Overrides ReadOnly Property AreaName() As String
        Get
            Return "Admin"
        End Get
    End Property

    Public Overrides Sub RegisterArea(ByVal context As System.Web.Mvc.AreaRegistrationContext)
        context.MapRoute( _
            "Admin_default", _
           "Admin/{controller}/{action}/{id}", _
            New With {.action = "Index", .id = UrlParameter.Optional} _
        )
    End Sub
End Class

I created an "AdminController" and an appropriate view and built the project. Trying to navigate to

/Admin

/Admin/Admin

/Admin/Admin/Index

All ends in failure

Generic 404

I tried deleting the Admin area and created a new one called Dashboard with an Admin controller.

Folder structure

I also modified my MapRoute

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

I tried every combination of namespace for DashboardAreaRegistration

Namespace Areas

Namespace Areas.Dashboard

Namespace Dashboard

I tried every combination of namespace for AdminController

Namespace Areas

Namespace Areas.Dashboard

Namespace Areas.Controllers

Namespace Areas.Dashboard.Controllers

I also tried including the namespace in \App_Start\RouteConfig.vb

Imports Areas

Imports Areas.Dashboard

Imports Areas.Dashboard.Controllers

No change, just 404. What can I do?

Was it helpful?

Solution

After 2 days I finally resolved this issue, and I have no idea why this worked.

In my main Web.config I found

<section name="glimpse" type="Glimpse.Core.Configuration.Section, Glimpse.Core" />

This is line for Glimpse - a NuGet package that I installed to try to help resolve my problem in the first place. One of its features is assisting with routing debugging. Note that the problem occurred exactly the same before and after I installed Glimpse; so I don't think it's related.

  1. I deleted this line
  2. Saved Web.config
  3. Refreshed my browser, I got an error (500)
  4. Put the line back in
  5. Saved again
  6. Refreshed the page again, everything worked; I can access /Dashboard

Some sort of glitch or corruption?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top