上下文: 我目前正在開發我的第一個MVC應用程序,我正在遵循Steven Sanderson在「Pro ASP.NET MVC Framework 2」一書中的示例。 我跟着第一章節和我已經實現了類似的應用的「SportStore」全碼可位於下面的鏈接http://pastie.org/2451370ASP.NET MVC中的路由混淆
的應用已兩個控制器
1 .- NavController設計以實施一個用戶使用用戶控制「Menu.ascx」菜單
2 .- PostEntryController設計能夠列出屬於
運行在調試模式NavController應用程序時,問題就出現生成的鏈接不要W A某菜單選項後由於某種原因,PostEntryController沒有實例化。
當我檢查源代碼生成的aspx文件顯示爲(後補/的Index.aspx)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="/MarsWeb/Content/Site.css" rel="stylesheet" type="text/css" />
<link href="/MarsWeb/Content/jquery.treeview.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/MarsWeb/Scripts/jquery-1.4.1.js"></script>
<script type="text/javascript" src="/MarsWeb/Scripts/jquery.treeview.js"></script>
<script type="text/javascript" src="/MarsWeb/Scripts/jquery-treeview-1.4.0.min
</script>
<script type="text/javascript">
$(function() {
$("#browser").treeview({collapsed: true,animated: "medium",control: "#categories",
unique: true,persist: "location"});})
</script>
<title>Posts</title></head>
<body>
<div id="header">
<div id="title">
<h1>Mars Ventas</h1>
</div>
</div>
<div id="categories">
<ul id="browser" class="filetree">
<li><span class="folder"><a href="/PostEntry/Index/0/1">Home</a></span></li>
<li><span class="folder"><a href="/PostEntry/Index/2/1">Ventas</a></span></li>
<li><span class="folder"><a href="/PostEntry/Index/3/1">Avance de Ventas</a></span></li>
<li><span class="folder"><a href="/PostEntry/Index/4/1">Browser</a></span></li>
</ul>
</div>
</html>
誰能幫助我?
這是Global.asax中
routes.MapRoute("PostEntry", "PostEntry/{action}/{MenuItemId}/{page}", // Matches ~/MenuId
new { controller = "PostEntry", action = "Index", MenuItemId = (string)null },
new { page = @"\d+" }
);
routes.MapRoute("MenuItem", "PostEntry/{action}/{MenuItemId}", // Matches ~/MenuId
new { controller = "PostEntry", action = "Index", MenuItemId = (string)null, page = 1 }
);
routes.MapRoute(null, "", // Only matches the empty URL (i.e. ~/)
new { controller = "PostEntry", action = "Index", MenuItemId ="0", page = 1}
);
當我寫在地址欄裏我可以訪問網址
您應該回頭並在以前的問題上標記答案以獲得更多幫助。與此同時,您是否可以從Global.asax發佈您的路線? –
鏈接看起來沒問題 - 問題必須在其他地方。你可以添加控制器代碼嗎? –
完整的代碼在http://pastie.org/2451370 – Guillermo