tags:

views:

37

answers:

2

I have an MVC application with custom view engine implementing theme selection, i.e. dynamic setting of views' master pages. The app structure is described here The issue is that master pages exist out of their default location in Views folder. (That is because I want all theme-related files, ie. css and images to be at one place together with master. Putting css into Views would break security issue - default views' web.config won't allow to access anything there and I'd rather keep it that way.) Everything works fine until I try to change master page to be strongly typed, ie specify

<%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage<MyApp.Models.BaseModel>" %>

Then the page throws error:

Could not load System.Web.Mvc.ViewMasterPage < MyApp.Models.BaseModel >

.

So, is there any way to import that namespace to where it's required? To change some setting in web.config (in Views folder, I assume) or elsewhere?

A: 

You could always pass the information as ViewData and cast it back into a strong type. Or you could create a ViewDataFacade class so the casting is handled in the classes themselves.

Dan Atkinson
A: 

This is a guess... but you get errors along those lines when you try to use namespaces in your view code (e.g. for HTML Helpers) that the view engine can't reference, and you solve this by adding it to web.config in the section.

So perhaps this would fix it?

<add namespace="MyApp.Models"/>
AndyB