私は単純な Web ページ (一種のブログ) を書いていますが、次の問題でブロックされています。Views/Shared in _Layout.cshtml で、ページのレイアウトを定義しました。
私のルーティングルールは次のようになります
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"paging", // Route name
"Home/GetArticleListForCategory/{id}/{pageNo}", // URL with parameters
new { controller = "Home", action = "GetArticleListForCategory", id = UrlParameter.Optional, pageNo = UrlParameter.Optional } // Parameter defaults
);
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
リンク http://localhost:3282/Home/GetArticleListForCategory/1からアクションを実行すると 、ページが正しく表示されます
リンク http://localhost:3282/Home/GetArticleListForCategory/1/1からアクションを実行すると 、ページは「未加工」に見えます(ページにレイアウトや画像などはありません)。2 つのリンクからページによって返される html を比較しました。しかし、それらは同一です。コントローラーのアクションは次のようになります。
public ActionResult GetArticleListForCategory(int id,int pageNo = 1)
{
int articlesPerPageNo = ConfigurationHelper.NoOfArticlePerPage;
int totalNoOfArticles;
List<PostShort> listOfPostforCategory = GetListOfShortArticles(pageNo,articlesPerPageNo ,out totalNoOfArticles);
int totalPagesNo = (totalNoOfArticles + articlesPerPageNo - 1) / articlesPerPageNo;
ViewData["PageTotal"] = totalPagesNo;
ViewData["PageNo"] = pageNo;
return View("CategoryPosts",listOfPostforCategory);
}
パラメーターが適切にアクションに渡されることに注意してください (デバッグでテスト済み)。
そのような行動の原因と解決方法を知っている人はいますか?
助けてくれてありがとう。よろしくお願いします