ورود

View Full Version : url routing



resident
چهارشنبه 18 تیر 1393, 23:20 عصر
سلام.
url routing من به این صورت تعریف شده:

routes.MapRoute(
name: "Default2",
url: "{controller}/{action}/{slug}",
defaults: new { controller = "Main", action = "Index" }
);

routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}/{slug}",
defaults: new { controller = "Main", action = "Index", id = UrlParameter.Optional, slug = UrlParameter.Optional }
);

و لینکی دارم به این صورت:

<a href="@Url.Action("ShowArticle", new { id = item.Id ,slug=GenerateSlug(item.Title)})" target = "_blank">@Html.DisplayFor(modelItem => item.Title)</a>

وقتی روی این لینک کلیک میشه url ساخته شده به این صورته:

http://domain.com/Speech/ShowSpeech/اشتباهات-رایج?id=17 (http://domain.com/Speech/ShowSpeech/اشتباهات-رایج?id=17)

در حالیکه میخوام به این صورت باشه:

http://domain.com/Speech/ShowSpeech/17/اشتباهات-رایج (http://localhost:3641/Speech/ShowSpeech/17/%D8%A7%D8%B4%D8%AA%D8%A8%D8%A7%D9%87-%D8%AA%D8%B1-%D8%A7%D8%B2-%D8%A7%D8%B4%D8%AA%D8%A8%D8%A7%D9%87)

کجای مسیردهی ام اشتباهه؟

hadi0x7c7
جمعه 20 تیر 1393, 00:08 صبح
به اینجا (http://stackoverflow.com/questions/16096716/mvc4-routing-html-actionlink-and-html-routelink-producing-wrong-urls)یه نگاه بیندازید شاید جوابتون رو بگیرید