范县网站制作【范县网站优化】范县建网站、范县微信公众号运营、范县网页设计、范县微信小程序商城

范县,隶属河南省濮阳市,位于中国河南省东北部,濮阳市东部,黄河下游北岸。与濮阳市的濮阳县、台前县以及山东聊城市的莘县、阳谷县接壤,与山东省菏泽市的鄄城县、郓城县隔黄河相望,属暖温带季风气候,四季分明,温度适宜。 辖8镇4乡和1个范水办事处(筹),面积617平方公里,耕地54万亩,574个行政村,56万人 [1] 。
范县历史悠久,西汉初(公元前206年)始置县,以南临范水而得名,迄今已有2200余年历史,是范、顾、姚等姓氏的起源地,“扬州八怪”之一的郑板桥,曾在此任县令五载,境内现存有丹朱文化遗址、闵子墓、苏佑墓、范武子墓等文化古迹。
2006年6月,位于河南省濮阳市颜村铺乡境内的革命旧址,被国务院命名为“国家级文物保护单位”。 [2] 2017年,范县被列入国家园林县城。 [3]
2019年,一般公共预算收入完成8.17亿元,同比增长10.6%;全县生产总值完成213.64亿元,增长7%;规模以上工业增加值增长9.6%;社会消费品零售总额完成86亿元,增长9.8%;居民人均可支配收入完成14966元,增长9.3%;工业用电量完成10.86亿千瓦时,同比增长8.12%。 [1]
2020年2月26日,河南省人民政府批准范县退出贫困县,正式脱贫摘帽。 [4] 2020年7月29日,入选2019年重新确认国家卫生乡镇(县城)名单。 [5]
最近我们已经将大部分我们ASP.NET Web Form页面转换为使用ASP.NET MVC。当这个并不是一个小的工程的时候,使用一个新的URL结构并支持旧的URL是很有需要的。这个想法是,当你点击一个不存在的页面的时候,你会被定位到MVC里面合适的Controller和Action中去。
流程
1. 一个来自你的网站的旧形式的URL请求.例如:http://www.server.com/Users/Login.aspx
2. ASP.NET routing 拦截这个请求并匹配你RouteCollection中的一个Route
3. 并不是使用 MvcRouteHandler, 而是 LegacyRouteHandler 被调用.
4. 使用 LegacyRouteHandler, 它将会使用你指定的Route重定向名来产生MVC URL,并发出一个定位到http://www.server.com/site/login的HTTP 301 请求.
Routing
首先,我们需要定义我们的旧版Route类。这是必需的,因为我们需要暴露一个额外的属性来允许我们的routing处理器来找到正确的MVC route。
// 旧形式URL的route类,暴露一个RedirectActionNamepublic class LegacyRoute : Route
{ public LegacyRoute(string url, string redirectActionName, IRouteHandler routeHandler)
: base(url, routeHandler)
{
RedirectActionName = redirectActionName;
} public string RedirectActionName { get; set; }
}然后,我们需要定义route handler和关联的http handler。Route handler继承自IRouteHandler,而当创建你的旧形式URL routing的时候要使用这个类。Http handler继承自MvcHandler,因为它会为我们提供一些关键的信息,例如RequestContext。你也许会注意到你需要从request上copy所有的querystring参数(代码中并没有写出来)。这是必需的一步,因为GetVirtualPath方法调用时会需要所有的route data(来自RouteData.Values)并尝试利用它来创建URL。
LegacyRouteHandler : IRouteHandler
{ IHttpHandler GetHttpHandler(RequestContext requestContext)
{ LegacyHandler(requestContext)
}
}
LegacyHandler : MvcHandler
{ LegacyHandler(RequestContext requestContext) : (requestContext) { } ProcessRequest(HttpContextBase httpContext)
{ redirectActionName = ((LegacyRoute)RequestContext.RouteData.Route).RedirectActionName;
VirtualPathData data = RouteTable.Routes.GetVirtualPath(RouteContext, redirectActionName, RouteContext.RouteData.Values);
httpContext.Status = "";
httpContext.AppendHeader("", data.VirtualPath);
}
}最后,你需要在Global.asax文件中创建你的routes。记住,在配置routing的时候这是必需的一步。
public void RegisterRoutes(RouteCollection routes)
{
routes.MapRoute("Login", "site/login", new {
controller = "Users",
action = "DisplayLogin"
});
routes.Add("", new LegacyRoute(
"Users/Login.aspx",
"Login", new LegacyRouteHandler()
));
}
就是这样。当一个请求来到的时候,你会在Fiddler中看到如下的信息:
A request on "Users/Login.aspx"
A HTTP 301, with a header "Location" and value of "site/login"
A request on "site/login"
Final Thoughts
Granted, there's more you can do with this - like creating your own extension methods like MapRoute and doing better handling of finding the route, but this should get you started. Also, I'm writing the code off the top of my head, so there's no guarantee that any of it works as-is. Please let me know if you have any other thoughts.
Lastly, for those wondering why are we using a HTTP 301 status code? Well read up on them. "301 Moved Permanently" indicates "that all future requests should be directed to the given URI." While your end users will not see any difference other than a new URL in the browser, the 301 status code more aimed towards search engines to update their URL's in their indexes.
范县网站制作【范县网站优化】范县建网站、范县微信公众号运营、范县网页设计、范县微信小程序商城