Using A Spark master layout with Razor view
Asked Answered
C

2

5

I'm working on a project where Spark has been used as the View engine, and the decision has been made to switch to Razor.

I have managed to get Razor and Spark working nicely side by side in one project. The only issue is when I create a Razor view it obviously doesn't inherit the layout and styles form the Spark master layout.

Is there anyway I can do this without creating a Razor duplicate?

Clinometer answered 20/4, 2011 at 14:24 Comment(0)
R
7

This won't be possible because while the naming may be similar (sections/partials etc), the implementation details vary substantially because the rendering systems behind Spark and Razor/WebForms differ in strategy. Razor performs it's rendering with dependencies on ASP.NET itself to take the parsed result, whereas Spark uses its own 3-pass rendering system to produce class files for views.

Your best bet is to copy the master layout, convert to cshtml with all the various semantics implemented for Razor, and then each view you convert over to Razor, just point it to the new master page. It really won't be worth the time spent trying to get a custom shim in there given the copy-paste option in this case is low-tech and guaranteed to work.

Hope that helps,
Rob

Rosio answered 21/4, 2011 at 9:48 Comment(0)
M
1

The easiest (though potentially labor-intensive, depending on how complex you master view is) solution would be to create a duplicate layout.

Otherwise, here's a blog post about mixing WebForms and Razor views and layouts: http://www.hanselman.com/blog/MixingRazorViewsAndWebFormsMasterPagesWithASPNETMVC3.aspx. It's pretty much a hack but it could probably be adapted to work with Spark.

Mercia answered 20/4, 2011 at 16:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.