我正在制作简单的网站,我犯了一个菜单,我希望做重定向其他视图当我点击链接是菜单Url.Action不工作的布局页
<!DOCTYPE html>
<html>
<head>
<title>@Page.Title</title>
@RenderSection("head", required: false)
<style>
body {
margin: 0;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
width: 25%;
background-color: #555;
position: fixed;
height: 100%;
overflow: auto;
}
li a {
display: block;
color: white;
padding: 8px 16px;
text-decoration: none;
}
li a.active {
background-color: #4CAF50;
color: #000;
}
li a:hover:not(.active) {
background-color: #f1f1f1;
color: #000
}
</style>
</head>
<body>
<div>
<ul>
<li><a href="@Url.Action("KitapGoruntule","Home")">Kitapları Görüntüle</a></li>
<li><a href="#news">Kitap Kiralama</a></li>
<li><a href="#contact">Öğrencileri Görüntüle</a></li>
<li><a href="#about">Öğrenci Ekle</a></li>
<li><a href="#about">Kitap Ekle</a></li>
<li><a href="#about">Kiralanmış Kitap Listesi</a></li>
<li><a href="#about">Görevli Atama</a></li>
<li><img src="~/img/tpl_logo.gif" style="height:130px;width:325px;margin-left:5px" /></li>
</ul>
</div>
<div style="margin-left:25%;padding:1px 16px;height:1000px;">
@RenderBody()
</div>
</body>
</html>
这对是我的主页。当我添加@ Url.Action Url在当前上下文中不存在。当我如“KitapGoruntule” clickedd上我想在家里名开的观点是KitapGoruntule
有没有在您的Route.Config一个匹配的路由,并在控制器匹配的行动? –
检查@AlanBuchanan所说的并考虑使用@Html.ActionLink。 – Spectarion
@AlanBuchanan我如何理解匹配我是mvc的新手可以向我解释更多 –