MVCルーティングを読んだ後、自分で答えを出さなかった後、助けを期待しています。
以下のルートを登録しています。
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
null,
"YourFeedback/Article/{resourceId}",
new { controller = "YourFeedback", action = "Index", contentTypeId = new Guid(ConfigurationManager.AppSettings["ArticleLibraryId"]) });
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults
);
}
aspx ビューに次の ActionLink があります。
<%=Html.ActionLink("Your Feedback", "Article", "YourFeedback", new
{
resourceId = Model.ContentId.ResourceId
}, new { @class = "yourFeedback" })%>
MVC ルーティングについての私の理解では、これにより、「/YourFeedback/Article/101」という href を持つアンカー リンクがレンダリングされます。ここで、101 は Model.ContentId.ResourceId から取得されます。
ただし、アンカー リンクの href は「YourFeedback/Article/resourceId=101」としてレンダリングされます。
私が間違っているアイデアはありますか?
前もって感謝します。