Reputation: 855
I created a simple ActionResult
in AccountController
that should redirect to a specific URL:
[Route("account/redirect")]
public ActionResult RedirectGoogle()
{
return Redirect("https://google.com");
}
And I want to call the action in view using Razor like this:
<a class="btn btn-primary" href="@Url.Action("RedirectGoogle","AccountController")"> Goto Google</a>
but when clicking the link, nothing happens and the action is not even called. What am I doing wrong?
Upvotes: 0
Views: 513
Reputation: 18975
You need remove controller text in Url.Action
, change to
<a class="btn btn-primary" href="@Url.Action("RedirectGoogle","Account")"> Goto Google</a>
Upvotes: 2