November Happy Hour will be moved to Thursday December 5th.

MVC Routing

Vote:
 

Completely new to both EPiServer and MVC, so bear with me... :) Let me preface this by saying that I have no intention of using the CMS capabilities of EPiServer. We only own the product because they bout the eCommerce framework we use in our app. So the intention is to set up an EPi site simply for the purpose of using the Commerce functionality. The CMS side will never be used.

I have a site built with C#/MVC 5.0 that works perfectly without EPi in the mix, but as soon as I add EPi in, my default routing no longer works - in fact, all routing seems to have stopped working. This site was created by creating a new EPi site via the VisualStudio extension and then copying the files from the original MVC site into the newly created site.

No matter what url I go to, I am getting a 404 error. I have a RouteConfig file in my App_Start folder that contains the code shown below. Ideally I would want to go to the url http://myserver and have it use the Default action defined in my Home controller.

Any help is appreciated.

public class RouteConfig
{
	public static void RegisterRoutes( RouteCollection routes )
	{
		routes.IgnoreRoute( "{resource}.axd/{*pathInfo}" );

		routes.MapRoute(
			name: "Default",
			url: "{controller}/{action}/{id}",
			defaults: new { controller = "Home", action = "Default", id = UrlParameter.Optional }
		);
	}
}
#116324
Jan 28, 2015 16:05
Vote:
 

You do not need to add that route, EPiServer will do it for you (Yes, it takes over all the routing.....)

So, remove this and it should work

routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Home", action = "Default", id = UrlParameter.Optional }
        );
#116331
Jan 28, 2015 16:43
Vote:
 

I removed the route defintition and recompiled, but still no luck...

Going to http://myserver or http://myserver/Home/Default both land me on a 404.

Is there something I need to configure in EPi?

#116333
Jan 28, 2015 16:50
Vote:
 

Strange

Does http://myserver/EPiServer work (or what you are using as the UI-address)?

#116334
Jan 28, 2015 16:53
Vote:
 

Yes, that url bring me to the CMS login page

#116335
Jan 28, 2015 16:55
Vote:
 

Then the routing seem to work and you need to make shore you have a startpage.

Have you configured that?

#116338
Jan 28, 2015 17:24
Vote:
 

Yes, but I probably have it wrong.  Like I said, I am very new to EPiServer and have no real idea what I am doing. I can find no clear and concise documentation on how to set up a new site with MVC.  All the docs seems to be WebForms centric.  A link to any resources you may know would be awesome.

#116339
Edited, Jan 28, 2015 17:52
Vote:
 

Here is a good guide on how to do it

http://world.episerver.com/documentation/cms/get-started-with-cms/4-Creating-your-project/

#116344
Jan 28, 2015 20:17
Vote:
 

I saw that, but it ends up creating a page called start.aspx so I had assumed it was for WebForms...

Also, this assumes you will be using EPi for content - I am not.  I am only interested in the Commerce capabilities.  I want to ignore EPi content management completely. From what I can tell this method means I will have to edit and publish my content for all of my pages from EPi and that is not what I want.  I basically want to be able to enter a url and have it use the appropriate controller as it does in a non-EPi MVC site.

Is this even possible?  Am I missing something?

#116345
Jan 28, 2015 20:46
Vote:
 

You can use aspx in MVC (https://msdn.microsoft.com/en-us/library/dd381412%28v=vs.108%29.aspx)

Ok, then I am lost, sorry to say, I do not know Commerce I am said to say. Good luck, I am sure some other Commerce expert will help you

#116348
Jan 28, 2015 21:28
Vote:
 

Thanks for your help!

#116349
Jan 28, 2015 21:32
* 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.