Barry Franklin
Barry Franklin

Reputation: 1820

The controller path for '/null' was not found or does not implement IController

I have existing asp.net web forms applications that I have added RouteConfig.RegisterRoutes(RouteTable.Routes); to their global.asax files. I'm attempting to use some MVC alongside the forms - like friendly urls. The code is pretty standard and includes this:

 public static void RegisterRoutes(RouteCollection routes)
 {
     var settings = new FriendlyUrlSettings { AutoRedirectMode = RedirectMode.Permanent };
     routes.EnableFriendlyUrls(settings, new MyFriendlyUrlResolver());

     routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

     routes.MapRoute(
             name: "Default",
             url: "{controller}/{action}/{id}",
             defaults: new { action = "Index", id = UrlParameter.Optional }
         );
 }

It's all pretty much boilerplate code, aside from the custom friendly url resolver, so I'm not understanding why I am getting a lot of "The controller path for '/null' was not found or does not implement IController" errors now.

Am I getting a bunch of traffic to www.mysite.com/null now or does this have something to do with routing? Is there a special way to set up routing for a forms-heavy site? I have created new apps with forms + MVC and this is pretty much the code that the project comes with.

Upvotes: 1

Views: 86

Answers (1)

Akshay Phadke
Akshay Phadke

Reputation: 81

First of all be sure of your routing like if your route is

localhost/Home/Index

Also make sure that in your code behind file aspx.cs inherit the controller class like Public class Customer : Controller and then put a break point on your action method here it will be

 localhost/Customer/Add 

Then Check your aspx (design) page whether you are routing to the correct URL generally in MVC

 @Html.Action("Add", "Customer ", Model).

Check your global.asax file Application_onstart event nad make sure these two lines are present in this order

GlobalConfiguration.Configure(WebApiConfig.Register);            
RouteConfig.RegisterRoutes(RouteTable.Routes);

Upvotes: 1

Related Questions