We are in the process of updating the .NET mvc application from MVC3 to MVC5, which includes an upgrade from Razor 1 to Razor 3. One error that we continue to see in the views is the following:
In MVC3, many of our views do this:
@if (someCondition)
{
@* render some content *@
@string.Format(...)
}
However, in MVC5 this gives the following error:
System.Web.HttpParseException: Unexpected keyword "string" after "@" character. After inside the code, you do not need prefix constructs such as "string" with "@".
There are two simple fixes that I know of:
@if (someCondition)
{
@* render some content *@
@: @string.Format(...)
}
or
@if (someCondition)
{
@* render some content *@
<text> @string.Format(...) </text>
}
However, it will be painful to make and verify these changes in hundreds of submissions. So my question is: what is the best way to eliminate this seemingly violation?