301在asp.net中重定向来自数据库的动态url
问题描述:
我有成千上万的links
需要redirect
到new URL
使用301 Permanent Redirect
。我在数据库表中拥有所有这些urls
。我想知道应该在哪里加载这些网址(只有一次)。并且可以用于301永久重定向。301在asp.net中重定向来自数据库的动态url
的网址:
*RequestForURL* *301Redirect*
why-me/onboard-experience/food-and-drink-for-all-tastes/family-casual/-> /why-me/family-test/
why-me/onboard-experience/food-and-drink-for-all-tastes/room-service/-> /why-me/onboard-experience/food-for-all-tastes/
why-me/onboard-experience/food-and-drink-for-all-tastes/specialist-restaurants/-> /why-me/onboard-experience/food-for-all-tastes/
why-me/onboard-experience/food-for-all-tastes/me-deals/-> /why-me/onboard-experience/
why-me/onboard-experience/food-for-all-tastes/me-deals/wowsale2013.aspx /why-me/onboard-experience/
why-me/onboard-experience/food-for-all-tastes/dining-packages/-> /why-me/onboard-experience/food-for-all-tastes/
why-me/onboard-experience/food-for-all-tastes/drinks-packages/-> /why-me/onboard-experience/dazzling-entertainment/drink-packages/
why-me/onboard-experience/food-for-all-tastes/family-casual/-> /why-me/onboard-experience/food-for-all-tastes/
why-me/onboard-experience/food-for-all-tastes/room-service/ /why-me/onboard-experience/food-for-all-tastes/
why-me/onboard-experience/food-for-all-tastes/speciality-dining/-> /why-me/onboard-experience/food-for-all-tastes/
why-me/onboard-experience/types-of-me/-> /why-me/onboard-experience/
我使用VS 2013 Framework 4.0中
注:数据必须被加载只一次进入会议或第一个应用程序请求过程中。
答
负载值从Application_Start
数据库为静态Dictionary<string, string>
,然后检查BeginRequest
请求的URL,看它是否是在一个重定向辞典键存在,然后做context.Response.RedirectPermanent(value)
如果这样做。