/// <summary> /// 格式化Url过滤器 /// </summary> public class UrlFormatFilter : System.Web.Mvc.ActionFilterAttribute { /// <summary> /// 在Action执行前执行 /// </summary> /// <param name="filterContext"></param> public override void OnActionExecuting(System.Web.Mvc.ActionExecutingContext filterContext) { string url = filterContext.HttpContext.Request.Url.OriginalString; if (System.Text.RegularExpressions.Regex.IsMatch(url, "[A-Z]")) { url = url.ToLower(); filterContext.HttpContext.Response.StatusCode = 301; filterContext.HttpContext.Response.Redirect(url, true); } } }
/// <summary>
/// SEO始发城市Action
/// </summary>
/// <param name="code"></param>
/// <returns></returns>
[UrlFormatFilter]
[NoCacheFilter]
public ActionResult TejiaCity(string city)
{
city = city ?? string.Empty;
IBaseInfoSearch baseInfoService = ServiceFactory.BaseInfoSearch();
AirCityInfo cityInfo = baseInfoService.GetAirCityByName(city);
CityLowPriceViewModelBuilder builder = new CityLowPriceViewModelBuilder(cityInfo);
CityLowPriceViewModel model = builder.Build(this.ControllerContext);
// 初始化页面头
InitTejiaCityPageInfo(cityInfo);
InitlizeRegisterResource();
return View("TejiaCity", model);
}