Creating Vanilla MVC pages in an EPiServer MVC project

Vote:
 

I sometimes create a one off page to do data migration or other one off tasks. Before this has been a standard aspx webform which works fine - working outside of the CMS completely.

I'm creating an MVC project but i can't seem to do the same thing. If I create a simple (non EPiServer) view or controller I can't navigate to it. Example - controller MigrationController, action method Index(). The url {root}/Migration/Index doesn't work.

It's not a huge issue - just an oddity really. Is it possible to get these one off pages working with MVC or is it wise just to use web forms for this still. Does the EPiServer routing completely override the standard MVC routing thus making this impossible.

Just wondering really

#76832
Nov 04, 2013 13:12
Vote:
 

How does your RouteConfig look? Try adding:

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

    

Frederik

#76835
Nov 04, 2013 14:03
Vote:
 

Be aware that register the routes as Frederik suggest also opens up for requests like http://yoursite/StandardPage/ (given that you have a controller StandardPageController). The request will likely fail since there is no content routed to but it will give a 500 response rather than a 404.

To avoid that you can register a less generic route like:

routes.MapRoute(
   "Migration",
    "Migration/{action}/{id}",
     new { controller = "Migration", action = "Index", id = UrlParameter.Optional }
);

#76838
Nov 04, 2013 14:28
Vote:
 

Interesting, good tip Johan!

Frederik

#76841
Nov 04, 2013 16:41
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.