You should be able to use the @()
expression syntax:
<a class="@(User.Identity.IsAuthenticated ? "auth" : "anon")">My link here</a>
More Related Contents:
- Dynamic Anonymous type in Razor causes RuntimeBinderException
- Cascading drop-downs in MVC 3 Razor view
- Razor HtmlHelper Extensions (or other namespaces for views) Not Found
- MVC3 Razor DropDownListFor Enums
- In MVC3 Razor, how do I get the html of a rendered view inside an action?
- Checkbox for nullable boolean
- Pass parameter to controller from @Html.ActionLink MVC 4
- How to render a Razor View to a string in ASP.NET MVC 3?
- ASP.NET MVC 3 Razor: Include JavaScript file in the head tag
- HTML.ActionLink vs Url.Action in ASP.NET Razor
- How to add extra namespaces to Razor pages instead of @using declaration?
- How do I define a method in Razor?
- Localhost not working in chrome and firefox
- IntelliSense in Razor files (.cshtml) stopped working
- Can we use Razor syntax in ASP.NET Webforms (*.aspx pages)?
- Possible to access MVC ViewBag object from Javascript file?
- Is it possible to display raw Html from database in ASP.NET MVC 3?
- MVC 3 file upload and model binding
- Does Razor syntax provide a compelling advantage in UI markup?
- How to retain spaces in DropDownList – ASP.net MVC Razor views
- How to get the current view name in asp.net MVC 3?
- Razor doesn’t understand unclosed html tags
- Display encoded html with razor
- The view must derive from WebViewPage, or WebViewPage
- Html.DisplayFor not posting values to controller in ASP.NET MVC 3
- Share constants between C# and Javascript in MVC Razor
- Using System.Data.Linq in a Razor view
- Accessing a Session object from Razor _Layout.cshml
- How to use multiple form elements in ASP.NET MVC
- @media media query and ASP.NET MVC razor syntax clash