Antaris/RazorEngine — Issue #6: Bug: using a resolved Layout inside a strongly typed TemplateBase throws an ArgumentException
Author: sfmskywalker
Created: 2011-11-26 20:04:24+00:00
State: open

I have two razor views: Content.cshtml & Layout.cshtml.
I configured the TemplateService with a resolver that resolves the _Layout (which is set to "Layout.cshtml").
When I parse Content.cshtml while having the TemplateService configured to use a strongly typed TemplateBase<>, an exception is thrown from the CompilerServiceBase class in the method BuildTypeName:

"The template type is a generic defintion, and no model type has been supplied.".

The model type has indeed not been specified, since the Resolve method was called from the Resolver delegate without passing a model:

new DelegateTemplateResolver(x => _templateProvider.LoadTemplate(x)).

In summary: parsing a view (using a strongly typed TemplateBase) that has its _Layout property set to another view causes an ArgumentExeption: "The template type is a generic defintion, and no model type has been supplied.".