我正在使用 WebMatrix 实现 WebSecurity 功能,但它会在我的页面上产生错误!
该错误对我来说毫无意义:
代码:
<div class="signInOrRegister">
@if(WebSecurity.IsAuthenticated)
{
<h1>@WebSecurity.CurrentUserName</h1>
<p>You may view your Account Options by clicking <a href="#" class="ShowAccountToolbarAndMenu">View Account Options</a>
}
else
{
<h1>Sign In</h1>
<p class="signInSummary">Already a Customer? Sign In here.</p>
<div class="smallVerticalSpace"> </div>
<form action="@Request.ServerVariables["URL"]" method="post">
<table cellpadding="5" cellspacing="5" class="formTable">
<tr>
<td class="leftTD">
<label for="email" class="UsernameLabel">E-mail Address:</label><br />
<!--@Html.TextBox("Email", null, new { @class="email" })-->
</td>
<td class="rightTD">
<label for="password" class="customerIdLabel">Password:</label><br />
<!--@Html.Password("Password", null, new { @class="password"})-->
</td>
<td class="LastTD">
<label for="rememberMe" class="rememberMeLabel">Remember me?</label><br />
@Html.CheckBox("rememberMe")
<input type="submit" class="submit" value="Sign In" />
</td>
</tr>
</table>
</form>
}
</div>
错误:
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: The if block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup.
Source Error:
Line 42: <div class="signInOrRegister">
Line 43:
Line 44: @if(WebSecurity.IsAuthenticated)
Line 45: {
Line 46: <h1>@WebSecurity.CurrentUserName</h1>
Source File: /_SiteLayout.cshtml Line: 44
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1
因此,在阅读了错误之后,我确定没有任何内容被视为标记。我通过注释掉 @Html.TextBox("Email", new etc) 控件来做到这一点。但它仍然会产生同样的错误。这是怎么回事?我没有看到这里的问题。页面的其余部分只是静态 HTML,在我放入 WebSecurity 内容之前运行良好。
任何帮助表示赞赏
谢谢!