Area not working in MVC4 project in VB.NET

If you have had experience this problem then read ahead it is a simple fix.


Here are the step to reproduce this problem in Visual Studio


Here is what happened, I had a MVC4 project which was working fine. I created a new area called Admin.

Created a new controller and a view in the admin area. But when calling this view, it would give 404 error.

Tried few things and did some research on the net as usual.


Here is the simple fix which seems to work.

Go to your controller and add the namespace at the top . Just after the imports. Note that admin is the name of my area.

Change it according to your area name


Step 1

Imports System.Data.Entity

Namespace Areas.admin

You controller code is here

End Namespace


Step 2

Go to your Area and look for a file called

adminAreaRegistration.vb ( again admin is my area name, if your area is called sales then you should have a file called sales
AreaRegistration.vb. And your namespace will be Areas.sales.)

Ensure that the name space which you have in your controller  and the adminAreaRegistrarion.vb is the same

Namespace Areas.admin
Public Class adminAreaRegistration
Inherits AreaRegistration

Public Overrides ReadOnly Property AreaName() As String
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
End Namespace