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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:57:19+00:00 2026-05-25T12:57:19+00:00

I have a strange issue where an ActionLink won’t display. I have this code

  • 0

I have a strange issue where an ActionLink won’t display. I have this code in my view:

@if (User.IsInRole("Allow Create")) {
    Html.ActionLink("Add a new item", "Create");
}

I thought that maybe my roles and permissions weren’t set up correctly, but I went through the debugger, and sure enough the if-statement succeeds. It reaches the code to create the action link, and there are no errors.

But when the page loads, there is no link. It’s not hidden or anything either, it’s not in the source at all.

Anyone know what I’m doing wrong here?

  • 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-25T12:57:20+00:00Added an answer on May 25, 2026 at 12:57 pm

    you need an extra @

    @if (User.IsInRole("Allow Create")) {
        @Html.ActionLink("Add a new item", "Create");
    }
    

    As for the explanation: the @if (User.IsInRole("Allow Create")) { puts you inside a code block, and razor figures that you are just calling Html.ActionLink(..) as if you were calling a function while not bothering about the returned result. Since you actually want to output the result of the Html.ActionLink as html, you are mixing code and text for which you need the @ prefix.

    Just to illustrate, the following will have the same outcome as the code above:

    @if (User.IsInRole("Allow Create")) {
        var url = Html.ActionLink("Add a new item", "Create");
        @url;
    }
    

    Here is a nice Quick Reference

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

Sidebar

Related Questions

I have this strange issue with my web app. You see, I'm using jQuery
I have a strange issue with my code I can't seem to figure out.
I have a strange issue from a client in that our code, which they
I have this strange issue with some third party DLL's. The third party provider
I have a strange issue where the code works fine locally and on a
I have this strange issue. Xcode target does not find my 3rd party mac
I have a strange issue: there is a SectionPart with composite, which is create
I have a strange issue with my css navigation menu. The code is here:
So I have some strange issue with nl2br so I have the following code:
I have a strange issue with bluetooth socket. If I create socket and later

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.