2014-11-25 61 views
0

我有成千上萬的links需要redirectnew 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中

注:數據必須被加載只一次進入會議或第一個應用程序請求過程中。

回答

0

負載值從Application_Start數據庫爲靜態Dictionary<string, string>,然後檢查BeginRequest請求的URL,看它是否是在一個重定向辭典鍵存在,然後做context.Response.RedirectPermanent(value)如果這樣做。