Question

I have an action link inside a button that doesn't seem to be working:

<div style="position:absolute; top:0px; right:60px;">
    <button class="btn-top btn-vitae shadow-bottom">
        <a href="/Help" target="_blank">Help</a>
    </button>
</div>

The link is supposed to go to ActionResult Index in the HelpController:

public class HelpController : Controller
{
    //
    // GET: /Help/

    public ActionResult Index()
    {
        return View();
    }
} 

Am I missing something?

Was it helpful?

Solution

if memory serves you need to swap them

<a href="@Url.Action("Index", "Help")"><input type="button" class="btn-top btn-vitae shadow-bottom" /></a>

OTHER TIPS

Replace href="/Help" with @(Url.Action("Index", "Help"))

Using Url.Action you will be sure that the correct url is generated no matter what routing you're using.

your action link should include the controller name and action name like this

<a href="/Help/Index" target="_blank">Help</a>

or server side as suggested by @ssimeonov

One more way is to use Html.ActionLink (Instead of Anchor Tag) -

@Html.ActionLink("Help", "Index", "Home", null, new { target = "_blank" })
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top