We have a couple of MVC 3.0 web application some of them combination of Web Form and MVC3.0 within on project/solution.
I'm quiet new to sitecore, could someone please help me understand following in regards to migrating the existing application to Sitecore?
On what type of scenarios should we move MVC3.0 razor views to sitecore?
What are the key gotchas migrating MVC3.0 to sitecore?
Do I need to inject anything on sitecore pipeline?
Do I need to change any of the navigation links to work under sitecore?
Any link to sitecore best practice for migrating existing web app will be good.
I followed the blog below and still unclear why and when should we convert web control and razor views to Sitecore Rendering.
Thank you.
When migrating MVC applications into a Sitecore solution you have a few options available - depending on the nature of the component you are migrating you would have to choose the most appropriate option.
I'll try and address your 5 specific questions:
1. When to use Razor views
I'm not sure if the question is "when to use a Razor view" or if the questions is "when to use Sitecore View Rendering" - I'll assume the latter.
A View Rendering is great if your are writing presentation components that do not require any business logic and only deals with rendering items. If you are contemplating adding code in your Razor view you should probably consider if a Controller Rendering would be more appropriate or perhaps customising the mvc.getModel
pipeline.
2. Migration gotchas
Some of the things that may catch you out when migrating a MVC application to Sitecore.
3. Pipeline customisation
You are not compelled to customise the Sitecore pipelines. I can see a few examples where it would be useful to modify pipelines in the context of a migration story. One example I recently talked about at a Sitecore User Group involved adding a ActionFilter
globally (through mvc.resultExecuting
pipeline) that would inject a ASP.Net MVC application into a Sitecore place holder. In my example I injected the MVC Music Store into a placeholder and had Sitecore control window dressing (headers/footers/menus). This way I could bring my existing MVC application into Sitecore without having to change it much.
4. Navigation links
If your navigation endpoints are Sitecore item routes (e.i. the path to an item on the website) you should use Sitecore's LinkManager
to generate the appropriate links. If the endpoints are standard MVC routes RouteLink
and ActionLink
should work just fine.
I guess without a concrete example the answer will be "maybe".
5. Best practice migration blog post
I'm not aware of any blog posts or articles dealing with Sitecore MVC migration best practice. Keep in mind that full MVC support is a recent addition to Sitecore and not many seen this journey from start to end yet.
Why and when to convert to Sitecore Rendering
You end your question stating that you are still confused about when and why you would convert controls and Razor views to Sitecore renderings. Here are some indicators that something is a candidate for being a Sitecore rendering:
In the context of MVC here are some indicators that it may not be right to convert something to a Sitecore rendering:
I'm sure many of the points in this answer could be expanded on and I know that there are no clear cut rules for this - but I hope this answer helps clear up some of the confusion...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With