1

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など)コントロールをコメントアウトすることでこれを行いました。ただし、それでも同じエラーが発生します。どうしたの?ここでは問題はわかりません。ページの残りの部分は静的なHTMLであり、WebSecurityのものを入れる前は正常に機能していました。

どんな助けでも大歓迎です

ありがとうございました!

4

1 に答える 1

2

<p>ifステートメントで段落を閉じてみてください(47行目)。これがエラーの原因である可能性があります。

于 2011-03-18T07:17:58.427 に答える