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>
题
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" })