I have created a number of controllers and each of them returns a number of views.
The views get displayed successfully on the browser upon entering the url, for example: /localhost:21419/Accounting/Index
There is no problem with displaying views for any of the controller views except one(named OrderController)
For this OrderController, I get a 404 error when I enter the url on the browser. for example: /localhost:21419/Order/Index.
The only time I get a page display is when I enter /localhost:21419/Order (the Index page gets displayed). But when I enter /localhost:21419/Order/Index, I get the same error. I tried creating a new action method and a view corresponding to it, but none of the views under this controller are getting rendered. What might be the problem?
My Global.asax.cs :
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
RouteTable.Routes.MapHubs();
AreaRegistration.RegisterAllAreas();
WebApiConfig.Register(GlobalConfiguration.Configuration);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
}
My RouteConfig.cs (I added namespaces as well)
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
namespaces: new[] {"RRRPropPres.WebUI.Controllers"}
);
}
What might be the reason it doesn't work for one controller alone?
I tried
return View();
and
return View("name of View");
Nothing seems to help.
If the route works fine for other controllers, it will not be a problem with routes. You are getting a 404 and I doubt you do not have Index view under Order section. Click on the views->Order and see if Index is present. If no, we have to create one or we need to go further with your controller code. I could help further if you paste your controller code. The code snippets you pasted look all right. Right clicking on the controller and creating views might have placed your view in a different folder.