301重定向的动态网址在asp.net数据库 [英] 301 Redirect dynamic urls from database in asp.net
问题描述
我有成千上万的这必须链接
重定向
到新网址
使用 301永久重定向
。我有所有这些网址
在数据库表中。我想知道在哪里应该是这些URL应该被加载(仅一次)。并且可用于 301永久重定向。
I have thousands of links
which need to be redirect
to new URL
using 301 Permanent Redirect
. I have all these urls
in the Database table. I would like to know where should be these URLs should be loaded (only once). And can be used for 301 permanent redirect.
的网址:
*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框架4.0
注意: 数据必须被加载一次只进Session或第一个应用程序请求期间的
推荐答案
加载从的Application_Start
数据库中的值转换为静态词典<字符串,串>
,然后检查的BeginRequest
请求的URL,看它是否是在一个重定向字典项是否存在,然后执行 context.Response.RedirectPermanent(值)
如果这样做。
Load the values from the database in Application_Start
into a static Dictionary<string, string>
, then check the requested URL in BeginRequest
to see if it's key exists in a redirect dictionary, then do context.Response.RedirectPermanent(value)
if it does.
这篇关于301重定向的动态网址在asp.net数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!