PDA

View Full Version : مشکل در مسیریابی در mvc



shaki_phd
شنبه 30 آبان 1394, 19:07 عصر
سلام دوستان
یک سوال راجع به مسیریابی در mvc داشتم
من تو سایتم میخوام از سه نوع آدرس دهی استفاده کنم
1-www,site.com/rss.xml
2-www.site.com/amir
3-www.site.com/article/detail/1
متاسفانه به هرشکلی فایل RouteConfig را پر کردم نتوستم این سه نوع آدرس دهی را در کنار هم داشته باشم
درضمن نوع 3 نوع پیش فرض آدرس دهی من هستش
دوستان اگر کسی میدونه ممنون میشم کمکم کنه

shaki_phd
شنبه 30 آبان 1394, 19:17 عصر
اینم فایل RouteConfig



routes.MapRoute(
name: "RSS_route", // Route name
url: "rss.xml", // URL with parameters
defaults: new { controller = "Common", action = "RSS", area = "" } // Parameter defaults
, namespaces: new[] { "Clinic.WebUI.Controllers" }
);

routes.MapRoute(
name: "Doctor",
url: "{docname}",
defaults: new { controller = "Doctor", action = "Doctor", docname = "test" }
, namespaces: new[] { "Clinic.WebUI.Controllers" }
);

routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
, namespaces: new[] { "Clinic.WebUI.Controllers" }
);

routes.MapRoute(
name: "Article",
url: "{controller}/{action}/{id}/{subject}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional, subject = UrlParameter.Optional }
, namespaces: new[] { "Clinic.WebUI.Controllers" }
);