Skip to content
This repository was archived by the owner on Dec 19, 2018. It is now read-only.
This repository was archived by the owner on Dec 19, 2018. It is now read-only.

Exception filters cause Razor errors #402

Closed
@NTaylorMullen

Description

@NTaylorMullen

If you write:

@try
{
    throw new InvalidOperationException();
}
catch (Exception e) when (e.Message.Contains("Operation is not valid"))
{
}

You get the following error:

CompilationFailedException: Compilation for 'c:\......\Index.cshtml' failed:
Expected a "{" but found a "if". Block statements must be enclosed in "{" and "}". You cannot use single-statement control-flow statements in CSHTML pages. For example, the following is not allowed:

@if(isLoggedIn)
<p>Hello, @user</p>

Instead, wrap the contents of the block in "{}":

@if(isLoggedIn) {
<p>Hello, @user</p>
} 

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions