Examining the Generated cs File for a cshtml View

Cshtml files are compiled by Razor into C# files. To track down some errors (or just to understand Razor) it might be useful to examine the C# code generated.

For testing I created a small Razor view in an MVC4 project.

    string someString = "somestring";
    var someBool = false;
Some other text and @someString.

The easiest way to view the generated C# code is by introducing a compile error to bring up the compilation error page. I uncommented the – on line 4 (which obviously is incorrect C# code). In the bottom of the error page, there is a link to display the compilation source.

Software Development is a Job – Coding is a Passion

I'm Anders Abel, an independent systems architect and developer in Stockholm, Sweden.

profile for Anders Abel at Stack Overflow, Q&A for professional and enthusiast programmers

Code for most posts is available on my GitHub account.

Popular Posts



Powered by WordPress with the Passion for Coding theme.