【问题标题】:301 Redirect dynamic urls from database in asp.net301从asp.net中的数据库重定向动态url
【发布时间】:2015-01-23 00:20:25
【问题描述】:

我有数千个links,需要使用301 Permanent Redirectredirect 转换为new URL。我在数据库表中有所有这些urls。我想知道应该在哪里加载这些 URL(仅一次)。并可用于301永久重定向。

示例网址:

*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

注意: 数据只能在 Session 中或在第一次应用请求期间加载一次。

【问题讨论】:

    标签: asp.net url-routing http-status-code-301 global-asax


    【解决方案1】:

    Application_Start中的数据库中的值加载到静态Dictionary<string, string>中,然后检查BeginRequest中请求的URL以查看它的键是否存在于重定向字典中,如果存在则执行context.Response.RedirectPermanent(value)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-05-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-12
      • 2013-08-29
      相关资源
      最近更新 更多