Posts Tagged ‘razor’

Compile aspnet mvc views (*.cshtml)

Jan 26th, 2014

To make a long story short one can compile the views in asp net mvc.

It takes considerable time though so I only activate it for release compilations.

Update the build file with


1
<MvcBuildViews Condition=" '$(Configuration)' == 'Release' ">true</MvcBuildViews>

Like so:


1
2
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<MvcBuildViews Condition=" '$(Configuration)' == 'Release' ">true</MvcBuildViews>

I am sorry about all &gt; and &lt; but I don’t have the time right now to make everything look pretty. Just replace &gt; with < and &lt; with > and your good to go.
Or follow the links below with the awesome formatting Stack overflow provides.

Honour those who should. Especially this answer that does the only-release trick.

Exception in AspnetMvc with Razor: Parser Error Message: Expected “}”.

Apr 28th, 2012

The below text/error can occur if you have missed one of the } in jquery in a @section features{ section.

It can be hard tracking exactly which } is missing because commenting out the javascript code doesn’t change anything – it seems the razor engine doesn’t care about that type of comments.  Instead start the @section{} anew and copy-paste the code in again piece by piece.

In my case it was a totally ok javascript for loop:

for (i = 0 ; i < 12 ; i++) { }

Event though it is correct syntax it makes Razor fail.  Seems to be a bug in AspnetMVC/Razor/Dotnet4.5/Visualstudio11.
I am losing karma by not making the bug easy to reproduce and report the bug.

Server Error in ‘/myApplication’ Application. 

 

Parser Error 

Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Expected “}”.

Source Error:

Line 204:        </p>

Line 205:    </section>

Line 206:</section>