惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

美团技术团队
IT之家
IT之家
博客园 - Franky
博客园_首页
The Cloudflare Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
量子位
阮一峰的网络日志
阮一峰的网络日志
月光博客
月光博客
V
V2EX
Hugging Face - Blog
Hugging Face - Blog
博客园 - 三生石上(FineUI控件)
M
MIT News - Artificial intelligence
Engineering at Meta
Engineering at Meta
GbyAI
GbyAI
Stack Overflow Blog
Stack Overflow Blog
小众软件
小众软件
Jina AI
Jina AI
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 叶小钗
Apple Machine Learning Research
Apple Machine Learning Research
B
Blog RSS Feed

博客园 - Adam.Zhao

简单示例理解神闭包 ejs 模板使用方法 我使用的开源组件汇总,以备学习使用 了不起的Node.js--之五 TCP连接 Windows7下Java运行时环境搭建 了不起的Node.js--之四 了不起的Node.js--之三 了不起的Node.js--之二 了不起的Node.js--之一 请大家有需要购物的到我的网站上吧。 AngularJS应用骨架 最近在研究google的angularjs 好久没有来写博客了 c#二进制文件数据转换base64字符串文本代码 学习content-type 网站性能优化之服务端(一) 艺龙旅行网招聘了 关于项目管理的几点建议 HP CQ35 Windows7声卡驱动安装不上问题
ActionFilterAttribute做切面编程的Url的格式化例子
Adam.Zhao · 2012-02-11 · via 博客园 - Adam.Zhao
/// <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);
}