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 7525213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:28:47+00:00 2026-05-30T03:28:47+00:00

Why in the following Razor markup @foreach (var item in Model) { <tr> <td>@Html.DisplayFor(modelItem

  • 0

Why in the following Razor markup

@foreach (var item in Model) {
    <tr>
        <td>@Html.DisplayFor(modelItem => item.IncidentId)</td>
        ...
        <td>
            @Html.ActionLink("View", "View", new { id = item.IncidentId })
            @Html.ActionLink("Edit", "Edit", new { id = item.IncidentId })
            @{
            if (User.IsInRole("Manager"))
            {
                Html.ActionLink("Remove", "Remove", new {id = item.IncidentId});
            }
            }
        </td>
    </tr>
}

event when the user is Manager (I can confirm that the RoleProvider works fine, since while debugging I can see how the debugger steps into the code to call Html.ActionLink for the Remove), an actual action link doesn’t get rendered into the resulting html?

If I just place

@Html.ActionLink("Remove", "Remove", new { id = item.IncidentId })

it gets rendered fine.

  • 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-05-30T03:28:48+00:00Added an answer on May 30, 2026 at 3:28 am

    @{ } is a code block, values won’t get written to the response output by default.

    You could either do:

    @{
      if (User.IsInRole("Manager"))
      {
         @Html.ActionLink("Remove", "Remove", new {id = item.IncidentId});
      }
    }
    

    or:

    @if (User.IsInRole("Manager"))
    {
       @Html.ActionLink("Remove", "Remove", new {id = item.IncidentId});
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following razor markup: @{ var initValue = @Html.Raw(new JavaScriptSerializer().Serialize(Model)); @Html.Hidden(initial-namings-data, initValue.ToString());
I have the following in my ASP.Net MVC 3 Razor View @foreach (var item
Using the razor view engine, I have some code like the following: @Html.TextAreaFor(model =>
I am trying to render the following HTML using an MVC3 Razor View: <input
I would like to execute the following from within a razor view @Select.Topics(@Model.DataSource, @Model.ExamID,
I have the following markup in an MVC 3 Razor view. As is, the
This one is strange...I have the following markup for a view using Razor view
I have the following asp.net mvc 3 razor code, where item is my model,
I have the following markup as a part of a Razor view: <table> <caption>Presidents</caption>
In my razor view I have the following: var url = @Url.Action(Mvc.Leads.GetAllLeads()) var url2

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.