hmahdavi921
شنبه 14 مرداد 1396, 15:10 عصر
سلام
برای روتینگ سایت به این صورت عمل کردم.
public class BlogConstraint : IRouteConstraint {
private RouteDB routeDb = new RouteDB();
private Utility.Utility.CacheKeys _cachekeys = new Utility.Utility.CacheKeys();
public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection)
{
if (values["controller"].ToString().ToLower() != "blog" ||
values["Details"].ToString().ToLower() != "details" ||
values["id"] == null)
{
return false;
}
Dictionary<int, string> blogDic = new Dictionary<int, string>();
int idOrigin = 0;
string titleOrigin = "";
try
{
}
catch (System.Exception e)
{
return false;
}
}
}
routes.MapRoute( name: "BlogRoute",
url: "{controller}/{Details}/{id}/{BlogTitle}",
defaults: new { controller = "Blog", BlogTitle = UrlParameter.Optional },
constraints: new { permalink = new BlogConstraint() },
namespaces: new[] { "TravelEnterProject.Controllers" }
);
و الان میخوام با تغیراتی واسه Areas En هم این روتینگ رو پیاده سازی کنم
routes.MapRoute( name: "BlogRouteEn", /*changed*/
url: "En/{controller}/{Details}/{id}/{BlogTitle}",
defaults: new { controller = "Blog", BlogTitle = UrlParameter.Optional },
constraints: new { permalink = new BlogConstraintEn() },/*changed*/
namespaces: new[] { "TravelEnterProject.Areas.En.Controllers" } /*changed*/
);
الان وبلاگها رو نشون میده اما قالب صفحه قالب نسخه فارسیه. توجه کنین که layout صفحه مورد نظر قالب انگلیسی هست. تو این مورد شک نداشته باشین
برای روتینگ سایت به این صورت عمل کردم.
public class BlogConstraint : IRouteConstraint {
private RouteDB routeDb = new RouteDB();
private Utility.Utility.CacheKeys _cachekeys = new Utility.Utility.CacheKeys();
public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection)
{
if (values["controller"].ToString().ToLower() != "blog" ||
values["Details"].ToString().ToLower() != "details" ||
values["id"] == null)
{
return false;
}
Dictionary<int, string> blogDic = new Dictionary<int, string>();
int idOrigin = 0;
string titleOrigin = "";
try
{
}
catch (System.Exception e)
{
return false;
}
}
}
routes.MapRoute( name: "BlogRoute",
url: "{controller}/{Details}/{id}/{BlogTitle}",
defaults: new { controller = "Blog", BlogTitle = UrlParameter.Optional },
constraints: new { permalink = new BlogConstraint() },
namespaces: new[] { "TravelEnterProject.Controllers" }
);
و الان میخوام با تغیراتی واسه Areas En هم این روتینگ رو پیاده سازی کنم
routes.MapRoute( name: "BlogRouteEn", /*changed*/
url: "En/{controller}/{Details}/{id}/{BlogTitle}",
defaults: new { controller = "Blog", BlogTitle = UrlParameter.Optional },
constraints: new { permalink = new BlogConstraintEn() },/*changed*/
namespaces: new[] { "TravelEnterProject.Areas.En.Controllers" } /*changed*/
);
الان وبلاگها رو نشون میده اما قالب صفحه قالب نسخه فارسیه. توجه کنین که layout صفحه مورد نظر قالب انگلیسی هست. تو این مورد شک نداشته باشین