Mvc + Theme support

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
12 年 前
This is the overridden Layout property. This makes sure that the view name specified on the Layout property is processed using the view engine. A better solution would be to create either an extension method or a method on the WebViewPage class to process a view name through the view engine and return the view path. But this would require all Layout assignments to be modified. Since I don't want to modify all pages for the time being, I just made that.


public override string Layout
        {
            get
            {
                return base.Layout;
            }
            set
            {
                var layout = value;

                    var filename = System.IO.Path.GetFileNameWithoutExtension(layout);
                    ViewEngineResult viewResult = System.Web.Mvc.ViewEngines.Engines.FindView(ViewContext.Controller.ControllerContext, filename, "");

                    if (viewResult.View != null)
                    {
                        layout = (viewResult.View as RazorView).ViewPath;
                    }

                base.Layout = layout;
            }
        }
12 年 前
Thx for the sample :) send you a PM
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.