ASP.Net MVC 4 Areas not registering. HTTP 404 error from Visual Studio 2012

user919426

I have spent the whole day trying to get an existing MVC application to work.

I have a the following situation:

1) I started working on an existing ASP.Net MVC Application with a custom area

2) It is working well at the office

3) I am at home and I VPN'ed and got the latest code from TFS

4) It is building successfully but if I try to run it from within Visual Studio 2012, it cannot see the registered areas

HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following

URL and make sure that it is spelled correctly.

A default document is not configured for the requested URL, and directory browsing is not enabled on the server.

5) I created an ordinary MVC website (NO AreaRegistrations) and ran it in Visual Studio 2012, it gives no errors

6) I have tried RouteDebugger and I keep getting the following error:

Sequence contains no elements

I have also gotten stuck trying to resolve that. If there is another way to actually step into it to see where it is failing, it would help.

In the actual Area folder: MyProject\Areas\MyCustomArea I have

MyProject\Areas\MyCustomArea\AreaRegistration.cs:

using Mvc = System.Web.Mvc;

    namespace MyProject.Areas.MyCustom
    {
        public class AreaRegistration : Mvc.AreaRegistration
        {
            public override string AreaName
            {
                get { return "MyCustomArea"; }
            }

            public override void RegisterArea(Mvc.AreaRegistrationContext context)
            {
                RouteConfig.RegisterRoutes(context);
            }
        }
    }

And MyProject\Areas\MyCustomArea\RouteConfig.cs:

using System.Web.Mvc;
using System.Web.Optimization; // <-- DOES THIS REFERENCE HAVE AN IMPACT?

namespace MyProject.Areas.MyCustomArea
{
    public class RouteConfig
    {
        public static void RegisterRoutes(AreaRegistrationContext context)
        {

            context.MapRoute(
                "MyCustomArea_Default",
                "MyCustomArea/{controller}/{action}/{id}",
                defaults: new { action = "Index", id = UrlParameter.Optional },
                namespaces: new[] { "MyProject.Areas.MyCustomArea.Controllers" });
        }
    }
}

My App_Start Folder has NO Route.config.cs file

I have a MyProject\packages.config with the following:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
  <package id="RazorGenerator.Mvc" version="2.2.2" targetFramework="net45" />
  <package id="WebActivatorEx" version="2.0.5" targetFramework="net45" />
</packages>

I use System.Web.Optimization

My Web.config file has the following:

  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
    <pages>
      <namespaces>
        <add namespace="System.Web.Helpers" />
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Optimization" />
        <add namespace="System.Web.Routing" />
        <add namespace="System.Web.WebPages" />
        <add namespace="Kendo.Mvc.UI" />
      </namespaces>
    </pages>
  </system.web>

Is there anything I may need to do to get it to work, bearing in mind that it works at work and I use RazorGenerator as well as Web Optimization, if those have an impact

Sorry if it was too long

Richard

Ensure that AreaRegistration.RegisterAllAreas() is called in your application startup. The usual place is in Application_Start in global.asax.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

ASP.NET Server Error in '/' Application in Visual Studio 2012

From Dev

ASP.NET MVC 4 Bundles giving 404 error

From Dev

ASP.NET MVC and Visual Studio 2013: Compilation Error

From Dev

ASP.NET MVC4 application with nested areas

From Dev

Price for registering visual studio express 2012 for web

From Dev

How to create a new MVC 5 project using ASP.NET Identity in Visual Studio 2012?

From Dev

Visual Studio 2012 Update 4 error

From Dev

Error manually registering DevExpress controls in an ASP.NET MVC project

From Dev

Access Asp.net Mvc areas from different domain

From Dev

Visual Studio 2013 removing 2012 guid from project mvc4

From Dev

Partial model entity classes resets after updating model from database in ASP.NET, Visual Studio 2012?

From Dev

Weird Error Upgrading ASP.NET MVC from 4 to 5

From Dev

Why is my ASP.NET MVC route configuration causing an HTTP 404 error?

From Dev

Why is my ASP.NET MVC route configuration causing an HTTP 404 error?

From Dev

ASP.Net Membership (Visual Studio 2012 & Web Forms)

From Dev

how to install asp.net 4.5 in visual studio 2012

From Dev

Image not showing in ASP.net visual studio 2012

From Dev

How can I change the ssl port number for my asp.net mvc web application inside Visual Studio 2012

From Dev

ASP.NET MVC how to handle 404 error from Application_Error without rewriting the URL

From Dev

Organizing Areas in ASP.Net MVC 5

From Dev

Organizing Areas in ASP.Net MVC 5

From Dev

MSBuild compiling ASP.NET MVC4 application - designed using Visual Studio 2015

From Dev

How to Create an ASP.NET MVC 4 project in visual studio 2015

From Dev

Different 404 pages being returned from ASP.NET MVC 4

From Dev

HTTP Error 405.0 - Method not allowed error in asp.net mvc 4 post method

From Dev

Unhandled exception error Visual Studio 2012 and Allegro 4

From Dev

Visual Studio 2013 -> New Project -> ASP.Net MVC App -> Unspecified error e_fail

From Dev

Asp.net MVC- get resized image from requested url get 404 Error

From Dev

404 error in callback from bank site to my action in asp.net mvc

Related Related

  1. 1

    ASP.NET Server Error in '/' Application in Visual Studio 2012

  2. 2

    ASP.NET MVC 4 Bundles giving 404 error

  3. 3

    ASP.NET MVC and Visual Studio 2013: Compilation Error

  4. 4

    ASP.NET MVC4 application with nested areas

  5. 5

    Price for registering visual studio express 2012 for web

  6. 6

    How to create a new MVC 5 project using ASP.NET Identity in Visual Studio 2012?

  7. 7

    Visual Studio 2012 Update 4 error

  8. 8

    Error manually registering DevExpress controls in an ASP.NET MVC project

  9. 9

    Access Asp.net Mvc areas from different domain

  10. 10

    Visual Studio 2013 removing 2012 guid from project mvc4

  11. 11

    Partial model entity classes resets after updating model from database in ASP.NET, Visual Studio 2012?

  12. 12

    Weird Error Upgrading ASP.NET MVC from 4 to 5

  13. 13

    Why is my ASP.NET MVC route configuration causing an HTTP 404 error?

  14. 14

    Why is my ASP.NET MVC route configuration causing an HTTP 404 error?

  15. 15

    ASP.Net Membership (Visual Studio 2012 & Web Forms)

  16. 16

    how to install asp.net 4.5 in visual studio 2012

  17. 17

    Image not showing in ASP.net visual studio 2012

  18. 18

    How can I change the ssl port number for my asp.net mvc web application inside Visual Studio 2012

  19. 19

    ASP.NET MVC how to handle 404 error from Application_Error without rewriting the URL

  20. 20

    Organizing Areas in ASP.Net MVC 5

  21. 21

    Organizing Areas in ASP.Net MVC 5

  22. 22

    MSBuild compiling ASP.NET MVC4 application - designed using Visual Studio 2015

  23. 23

    How to Create an ASP.NET MVC 4 project in visual studio 2015

  24. 24

    Different 404 pages being returned from ASP.NET MVC 4

  25. 25

    HTTP Error 405.0 - Method not allowed error in asp.net mvc 4 post method

  26. 26

    Unhandled exception error Visual Studio 2012 and Allegro 4

  27. 27

    Visual Studio 2013 -> New Project -> ASP.Net MVC App -> Unspecified error e_fail

  28. 28

    Asp.net MVC- get resized image from requested url get 404 Error

  29. 29

    404 error in callback from bank site to my action in asp.net mvc

HotTag

Archive