Вопрос

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?

Это было полезно?

Решение

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>

Другие советы

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" })
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top