Goal:
- Use cshtml
Razortemplates to format data - Embed cshtml Razor templates in Class Library as
Embedded Resources - Use
Linqstatements and extension methods in the cshtml template
I created a new class library project, then adapted Scott Hanselman's instructions on how to integrate MVC3 into a WebForms application to get it to work in a Class Library. Then I use the NuGet package RazorEngine to apply the template to an object.
So far it works great, with one hiccup: The intellisense does not recognize Linq statements or extension methods (a pretty important part of MVC) when editing cshtml files.
So for the following cshtml file:
@model Customer[]
@Model.Count()
@if (Model.Where(customer => customer.Type == 'New').Any())
{
<span>Found at least one new customer.</span>
}
...it displays the following errors:
Feature 'extension method' cannot be used because it is not part of the ISO-2 C# language specification
Feature 'lambda expression' cannot be used because it is not part of the ISO-2 C# language specification
Does anyone know what I'm missing? Thank you in advance--I've spent hours searching for the answer to this.
Some additional details
The following is my web.config in the Views folder:
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section