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" }
);
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*/
);
برچسب:
نویسنده: خنج