Non EPiServer Pages within EPiServer MVC

Vote:
 

Hi All

Im currently working on my first EPiServer build, and I am doing it in MVC, which im also not an expert on either unfortunately, I am using the Alloy site as a base. The site I am working on though has a section that does not involve CMS driven content so I have created a controller for it and added a custom route for it in my Global.asax file so that I can access it on: www.mysite.com/mycontroller/{action}.

The problem I am having though is that my main Layout file that all pages are using make constant references to the Model, which is of type IPageViewModel<SitePageData> which expects the CurrentPage to be passed to it from EPiServer, but as my page does not use content form the EPiServer CMS, and does not live in the menu structure, there is no CurrentPage so I get NULL references all over the place. I really dont want to have to create a second Layout file that is almost identical but without the references to EPiServer, can anyone recommend a way of handling this? It does need to look like the rest of the site so the menus need to work, but will the menu fall over because the current page is not part of it when trying to compare for active states? Do I just need to put it in the menu but not render a link to it, if so can I create a template off of an action rather than just using Index? I realise this is a lot of questions, im just a little lost at the minute as to the point where EPiServer takes over from normal MVC architecture.

Any help to point me in the right direction would be greatly appreciated!!

Many Thanks
Dave

#71759
May 28, 2013 13:54
Vote:
 

The way I deal with this issue is  to create a simple pagetype for those non cms driven page and then use IPageViewModel as how it worked in other pages. That would be easy.

Alternatively, you have to create another layout, the reason you have IPageViewModel in your master view is to use the contents to control the layout or other shared properties like SEO stuffs. In your case, you page is not part of CMS, it doesn't make sense they can share the same master layout as your current layout may already access to the model property. 

#71780
May 29, 2013 4:39
Vote:
 

Hi Code Monkey

Thank you for your response. In the end I have just added it to the menu, I found this post:

http://world.episerver.com/Modules/Forum/Pages/Thread.aspx?id=65320&

That helped me out a lot with the routing so I think I have found a solution I am relatively happy with.

Thanks for your help

#71796
May 29, 2013 13:16
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.