Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7806511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:33:36+00:00 2026-06-02T02:33:36+00:00

I have the following code inside a partial view: @if (Request.IsAuthenticated) { Hello, @Html.ActionLink(User.Identity.Name,

  • 0

I have the following code inside a partial view:

@if (Request.IsAuthenticated)
{
    Hello, @Html.ActionLink(User.Identity.Name, "ChangePassword", "Account") | Html.ActionLink("Log off", "LogOff", "Account")
}
else
{
    @Html.ActionLink("Log in", "Login", "Account")
}

Expected output (with appropriate links to actions):

  • If logged in: Hello Jim | Log off
  • If not logged in: Log in

However, this results in errors:

  • Within VS, The word “Hello” has an error on it: “Cannot resolve symbol ‘Hello'” and “&#” has “Expression expected”
  • In the browser I get “CS1040: Preprocessor directives must appear as the first non-whitespace character on a line”

If I put a <p>...</p> around the line beginning with “Hello” the error goes away.

There is obviously some syntax error with my mixing calls to @Html and text within the same line. What is the correct way to do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T02:33:37+00:00Added an answer on June 2, 2026 at 2:33 am

    The contents of a code block ({ ... }) are expected to be code, not markup.

    If you want to put text directly in a code block, you have three choices:

    • Wrap it in any HTML tag
    • Wrap it in the special Razor <text> tag, which will just render the text without the tag
    • Prepend the line with @:, which is equivalent

    See SottGu’s blog post.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code inside the _forms view. <div class=field> Shop: <%= f.collection_select
I have the following code with a bool if statement inside and in another
Inside my template function I have the following code: TypeName myFunction() { TypeName result;
I have the following XAML code, which displays a picture (image inside borders) and
I have ASP.Net code similar to the following (this is inside a FIELDSET): <ol>
I Have following code: Controller: public ActionResult Step1() { return View(); } [AcceptVerbs(HttpVerbs.Post)] public
I have the following code inside a method: var list = new[] { new
I have the following code inside a class: this.buttons = { cancelButton:{buttonId: cancelButton, buttonText:Cancel,
I have the following code inside a Form, and am attempting to find a
Alright, probably not the best title, but meh. I have the following code inside

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.