What am I doing wrong? (Razor Syntax & WebSecurity)
I am implementing the WebSecurity feature with WebMatrix, but it produces errors on my page!
The error makes no sense to me:
Code:
<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>
The error:
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
So, after reading the error, I've made sure nothing's been treated as markup. I've done this by commenting-out the @Html.TextBox("Email", new etc) controls. But it still produces this same error. What's going on? I don't see the problem here. The rest of the page is just static HTML, and worked fine before I put the WebSecurity stuff in.
Any help is appreciated
Thank you!
try to close your paragraph <p>
wihtin your if-statement (Line 47)! This could be the cause of the error.
精彩评论