0

I'm getting this error in my cshtml file near this code

@{      
    var options = new OpenIdSelector();
    options.TextBox.LogOnText = "Log On";
}

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: Unexpected "{" after "@" character. Once inside the body of a code block (@if {}, @{}, etc.) you do not need to use "@{" to switch to code.


@using DotNetOpenAuth.Mvc
@using DotNetOpenAuth.OpenId.RelyingParty
@{ 
 ViewBag.Title = "Log On"; 
}
<div id="login-oauth">
        <h3>via 3rd Party (recommended)</h3>
        
        @{ Html.RenderPartial("LogOnContent");}


    </div>
    <div id="or">OR</div>
    <div id="login-account">
        <h3>using a account</h3>
         </div>
    @using (Html.BeginForm())
    {
        <div>
            <p>
                <label for="username">Username:</label>
                @(Html.TextBox("username"))
                @(Html.ValidationMessage("username", "*"))
            </p>
            <p>
                <label for="password">Password:</label>
                @(Html.Password("password"))
                @(Html.ValidationMessage("password", "*"))
            </p>
            <p>
                @(Html.CheckBox("rememberMe")) <label class="inline" for="rememberMe">Remember me?</label>
            </p>
            <p>
                <input class="classiclogon" type="submit" value="Log On" />
            </p>
            <p>
                Please enter your username and password. @(Html.ActionLink("Register", "Register")) if you don't have an account.
            </p>
        </div>
   
    
        
 @{     
     {
            var options = new OpenIdSelector();
            options.TextBox.LogOnText = "Log On";
}
        }
       @MvcHtmlString.Create(Html.OpenIdSelectorScripts(options, null))
   @* @(Html.OpenIdSelectorScripts(this.Page, options, null))*@
    
    }
2
  • 1
    It sounds like you're already in a code block not a mark-up block. What does the surrounding code look like? Does it work if you drop the @{ and }? Commented May 22, 2013 at 15:18
  • 1
    Show us the surroundings please. Commented May 22, 2013 at 15:19

1 Answer 1

6

You're already in the

@using (Html.BeginForm())
{

block, so your

var options = new OpenIdSelector();
options.TextBox.LogOnText = "Log On";

block does not have to begin with @{. Pretty much what the error says.

You can also just move those two lines to the code block at the top, where you set ViewBag.Title, to keep your HTML free from code as much as possible.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.