Home > Back-end >  Linking text to another page in ASP.NET MVC
Linking text to another page in ASP.NET MVC

Time:10-30

I want to redirect to another view in my application when user clicks to the hyperlinked text. I wrote the code like this:

<p class="mb-0">
    <a href="~/Views/Account/ApprovalValidation.cshtml">I want to check approval</a>
</p>

But it's not opening the page and returns an error saying that view cannot found that location.

Can anyone show me what I did wrong?

Here is a picture of the code:

enter image description here

CodePudding user response:

The Url.Action() method is the most convenient way of generating outgoing links:

<p class="mb-0">
    <a href="@Url.Action("ApprovalValidation", "Account")">I want to check approval</a>
</p>
  • Related