Search code examples
c#asp.net-mvcrazor

How to use URL helper in Root.Master


I am trying to set up this link in the Root.master file of my ASP.NET MVC project. But the @ symbol is not recognized as razor syntax. And the Action and Controller names are underlined in green with the message "Validation (HTML5): This attribute name must be followed by an equal sign and a value. If the value is in quotation marks, the quotation marks must match." Does something need to be installed for the @Url to be used? Or do I need to achieve this a different way? Thanks!

<a id="Link" href="@Url.Action("Action", "Controller")">Text</a>

Solution

  • You are in a .NET Framework project. Create a new .NET Core project to use razor @Url.Action.