1. using System;
  2. using System.Web;
  3. using System.Web.Routing;
  4. using Nop.Core;
  5. using Nop.Core.Data;
  6. using Nop.Core.Infrastructure;
  7. using Nop.Services.Events;
  8. using Nop.Services.Seo;
  9. using Nop.Web.Framework.Localization;
  10.  
  11. namespace Nop.Web.Framework.Seo
  12. {
  13. /// <summary>
  14. /// Provides properties and methods for defining a SEO friendly route, and for getting information about the route.
  15. /// </summary>
  16. public partial class GenericPathRoute : LocalizedRoute
  17. {
  18. #region Constructors
  19.  
  20. /// <summary>
  21. /// Initializes a new instance of the System.Web.Routing.Route class, using the specified URL pattern and handler class.
  22. /// </summary>
  23. /// <param name="url">The URL pattern for the route.</param>
  24. /// <param name="routeHandler">The object that processes requests for the route.</param>
  25. public GenericPathRoute(string url, IRouteHandler routeHandler)
  26. : base(url, routeHandler)
  27. {
  28. }
  29.  
  30. /// <summary>
  31. /// Initializes a new instance of the System.Web.Routing.Route class, using the specified URL pattern, handler class and default parameter values.
  32. /// </summary>
  33. /// <param name="url">The URL pattern for the route.</param>
  34. /// <param name="defaults">The values to use if the URL does not contain all the parameters.</param>
  35. /// <param name="routeHandler">The object that processes requests for the route.</param>
  36. public GenericPathRoute(string url, RouteValueDictionary defaults, IRouteHandler routeHandler)
  37. : base(url, defaults, routeHandler)
  38. {
  39. }
  40.  
  41. /// <summary>
  42. /// Initializes a new instance of the System.Web.Routing.Route class, using the specified URL pattern, handler class, default parameter values and constraints.
  43. /// </summary>
  44. /// <param name="url">The URL pattern for the route.</param>
  45. /// <param name="defaults">The values to use if the URL does not contain all the parameters.</param>
  46. /// <param name="constraints">A regular expression that specifies valid values for a URL parameter.</param>
  47. /// <param name="routeHandler">The object that processes requests for the route.</param>
  48. public GenericPathRoute(string url, RouteValueDictionary defaults, RouteValueDictionary constraints, IRouteHandler routeHandler)
  49. : base(url, defaults, constraints, routeHandler)
  50. {
  51. }
  52.  
  53. /// <summary>
  54. /// Initializes a new instance of the System.Web.Routing.Route class, using the specified URL pattern, handler class, default parameter values,
  55. /// constraints,and custom values.
  56. /// </summary>
  57. /// <param name="url">The URL pattern for the route.</param>
  58. /// <param name="defaults">The values to use if the URL does not contain all the parameters.</param>
  59. /// <param name="constraints">A regular expression that specifies valid values for a URL parameter.</param>
  60. /// <param name="dataTokens">Custom values that are passed to the route handler, but which are not used to determine whether the route matches a specific URL pattern. The route handler might need these values to process the request.</param>
  61. /// <param name="routeHandler">The object that processes requests for the route.</param>
  62. public GenericPathRoute(string url, RouteValueDictionary defaults, RouteValueDictionary constraints, RouteValueDictionary dataTokens, IRouteHandler routeHandler)
  63. : base(url, defaults, constraints, dataTokens, routeHandler)
  64. {
  65. }
  66.  
  67. #endregion
  68.  
  69. #region Methods
  70.  
  71. /// <summary>
  72. /// Returns information about the requested route.
  73. /// </summary>
  74. /// <param name="httpContext">An object that encapsulates information about the HTTP request.</param>
  75. /// <returns>
  76. /// An object that contains the values from the route definition.
  77. /// </returns>
  78. public override RouteData GetRouteData(HttpContextBase httpContext)
  79. {
  80. RouteData data = base.GetRouteData(httpContext);
  81. if (data != null && DataSettingsHelper.DatabaseIsInstalled())
  82. {
  83. var urlRecordService = EngineContext.Current.Resolve<IUrlRecordService>();
  84. var slug = data.Values["generic_se_name"] as string;
  85. //performance optimization.
  86. //we load a cached verion here. it reduces number of SQL requests for each page load
  87. var urlRecord = urlRecordService.GetBySlugCached(slug);
  88. //comment the line above and uncomment the line below in order to disable this performance "workaround"
  89. //var urlRecord = urlRecordService.GetBySlug(slug);
  90. if (urlRecord == null)
  91. {
  92. //no URL record found
  93.  
  94. //var webHelper = EngineContext.Current.Resolve<IWebHelper>();
  95. //var response = httpContext.Response;
  96. //response.Status = "302 Found";
  97. //response.RedirectLocation = webHelper.GetStoreLocation(false);
  98. //response.End();
  99. //return null;
  100.  
  101. data.Values["controller"] = "Common";
  102. data.Values["action"] = "PageNotFound";
  103. return data;
  104. }
  105. //ensre that URL record is active
  106. if (!urlRecord.IsActive)
  107. {
  108. //URL record is not active. let's find the latest one
  109. var activeSlug = urlRecordService.GetActiveSlug(urlRecord.EntityId, urlRecord.EntityName, urlRecord.LanguageId);
  110. if (string.IsNullOrWhiteSpace(activeSlug))
  111. {
  112. //no active slug found
  113.  
  114. //var webHelper = EngineContext.Current.Resolve<IWebHelper>();
  115. //var response = httpContext.Response;
  116. //response.Status = "302 Found";
  117. //response.RedirectLocation = webHelper.GetStoreLocation(false);
  118. //response.End();
  119. //return null;
  120.  
  121. data.Values["controller"] = "Common";
  122. data.Values["action"] = "PageNotFound";
  123. return data;
  124. }
  125.  
  126. //the active one is found
  127. var webHelper = EngineContext.Current.Resolve<IWebHelper>();
  128. var response = httpContext.Response;
  129. response.Status = "301 Moved Permanently";
  130. response.RedirectLocation = string.Format("{0}{1}", webHelper.GetStoreLocation(false), activeSlug);
  131. response.End();
  132. return null;
  133. }
  134.  
  135. //ensure that the slug is the same for the current language
  136. //otherwise, it can cause some issues when customers choose a new language but a slug stays the same
  137. var workContext = EngineContext.Current.Resolve<IWorkContext>();
  138. var slugForCurrentLanguage = SeoExtensions.GetSeName(urlRecord.EntityId, urlRecord.EntityName, workContext.WorkingLanguage.Id);
  139. if (!String.IsNullOrEmpty(slugForCurrentLanguage) &&
  140. !slugForCurrentLanguage.Equals(slug, StringComparison.InvariantCultureIgnoreCase))
  141. {
  142. //we should make not null or "" validation above because some entities does not have SeName for standard (ID=0) language (e.g. news, blog posts)
  143. var webHelper = EngineContext.Current.Resolve<IWebHelper>();
  144. var response = httpContext.Response;
  145. //response.Status = "302 Found";
  146. response.Status = "302 Moved Temporarily";
  147. response.RedirectLocation = string.Format("{0}{1}", webHelper.GetStoreLocation(false), slugForCurrentLanguage);
  148. response.End();
  149. return null;
  150. }
  151.  
  152. //process URL
  153. switch (urlRecord.EntityName.ToLowerInvariant())
  154. {
  155. case "product":
  156. {
  157. data.Values["controller"] = "Product";
  158. data.Values["action"] = "ProductDetails";
  159. data.Values["productid"] = urlRecord.EntityId;
  160. data.Values["SeName"] = urlRecord.Slug;
  161. }
  162. break;
  163. case "category":
  164. {
  165. data.Values["controller"] = "Catalog";
  166. data.Values["action"] = "Category";
  167. data.Values["categoryid"] = urlRecord.EntityId;
  168. data.Values["SeName"] = urlRecord.Slug;
  169. }
  170. break;
  171. case "manufacturer":
  172. {
  173. data.Values["controller"] = "Catalog";
  174. data.Values["action"] = "Manufacturer";
  175. data.Values["manufacturerid"] = urlRecord.EntityId;
  176. data.Values["SeName"] = urlRecord.Slug;
  177. }
  178. break;
  179. case "vendor":
  180. {
  181. data.Values["controller"] = "Catalog";
  182. data.Values["action"] = "Vendor";
  183. data.Values["vendorid"] = urlRecord.EntityId;
  184. data.Values["SeName"] = urlRecord.Slug;
  185. }
  186. break;
  187. case "newsitem":
  188. {
  189. data.Values["controller"] = "News";
  190. data.Values["action"] = "NewsItem";
  191. data.Values["newsItemId"] = urlRecord.EntityId;
  192. data.Values["SeName"] = urlRecord.Slug;
  193. }
  194. break;
  195. case "blogpost":
  196. {
  197. data.Values["controller"] = "Blog";
  198. data.Values["action"] = "BlogPost";
  199. data.Values["blogPostId"] = urlRecord.EntityId;
  200. data.Values["SeName"] = urlRecord.Slug;
  201. }
  202. break;
  203. case "topic":
  204. {
  205. data.Values["controller"] = "Topic";
  206. data.Values["action"] = "TopicDetails";
  207. data.Values["topicId"] = urlRecord.EntityId;
  208. data.Values["SeName"] = urlRecord.Slug;
  209. }
  210. break;
  211. default:
  212. {
  213. //no record found
  214.  
  215. //generate an event this way developers could insert their own types
  216. EngineContext.Current.Resolve<IEventPublisher>()
  217. .Publish(new CustomUrlRecordEntityNameRequested(data, urlRecord));
  218. }
  219. break;
  220. }
  221. }
  222. return data;
  223. }
  224.  
  225. #endregion
  226. }
  227. }

  

  1. using System.Web;
  2. using System.Web.Routing;
  3. using Nop.Core.Data;
  4. using Nop.Core.Domain.Localization;
  5. using Nop.Core.Infrastructure;
  6.  
  7. namespace Nop.Web.Framework.Localization
  8. {
  9. /// <summary>
  10. /// Provides properties and methods for defining a localized route, and for getting information about the localized route.
  11. /// </summary>
  12. public class LocalizedRoute : Route
  13. {
  14. #region Fields
  15.  
  16. private bool? _seoFriendlyUrlsForLanguagesEnabled;
  17.  
  18. #endregion
  19.  
  20. #region Constructors
  21.  
  22. /// <summary>
  23. /// Initializes a new instance of the System.Web.Routing.Route class, using the specified URL pattern and handler class.
  24. /// </summary>
  25. /// <param name="url">The URL pattern for the route.</param>
  26. /// <param name="routeHandler">The object that processes requests for the route.</param>
  27. public LocalizedRoute(string url, IRouteHandler routeHandler)
  28. : base(url, routeHandler)
  29. {
  30. }
  31.  
  32. /// <summary>
  33. /// Initializes a new instance of the System.Web.Routing.Route class, using the specified URL pattern, handler class and default parameter values.
  34. /// </summary>
  35. /// <param name="url">The URL pattern for the route.</param>
  36. /// <param name="defaults">The values to use if the URL does not contain all the parameters.</param>
  37. /// <param name="routeHandler">The object that processes requests for the route.</param>
  38. public LocalizedRoute(string url, RouteValueDictionary defaults, IRouteHandler routeHandler)
  39. : base(url, defaults, routeHandler)
  40. {
  41. }
  42.  
  43. /// <summary>
  44. /// Initializes a new instance of the System.Web.Routing.Route class, using the specified URL pattern, handler class, default parameter values and constraints.
  45. /// </summary>
  46. /// <param name="url">The URL pattern for the route.</param>
  47. /// <param name="defaults">The values to use if the URL does not contain all the parameters.</param>
  48. /// <param name="constraints">A regular expression that specifies valid values for a URL parameter.</param>
  49. /// <param name="routeHandler">The object that processes requests for the route.</param>
  50. public LocalizedRoute(string url, RouteValueDictionary defaults, RouteValueDictionary constraints, IRouteHandler routeHandler)
  51. : base(url, defaults, constraints, routeHandler)
  52. {
  53. }
  54.  
  55. /// <summary>
  56. /// Initializes a new instance of the System.Web.Routing.Route class, using the specified URL pattern, handler class, default parameter values,
  57. /// constraints,and custom values.
  58. /// </summary>
  59. /// <param name="url">The URL pattern for the route.</param>
  60. /// <param name="defaults">The values to use if the URL does not contain all the parameters.</param>
  61. /// <param name="constraints">A regular expression that specifies valid values for a URL parameter.</param>
  62. /// <param name="dataTokens">Custom values that are passed to the route handler, but which are not used to determine whether the route matches a specific URL pattern. The route handler might need these values to process the request.</param>
  63. /// <param name="routeHandler">The object that processes requests for the route.</param>
  64. public LocalizedRoute(string url, RouteValueDictionary defaults, RouteValueDictionary constraints, RouteValueDictionary dataTokens, IRouteHandler routeHandler)
  65. : base(url, defaults, constraints, dataTokens, routeHandler)
  66. {
  67. }
  68.  
  69. #endregion
  70.  
  71. #region Methods
  72.  
  73. /// <summary>
  74. /// Returns information about the requested route.
  75. /// </summary>
  76. /// <param name="httpContext">An object that encapsulates information about the HTTP request.</param>
  77. /// <returns>
  78. /// An object that contains the values from the route definition.
  79. /// </returns>
  80. public override RouteData GetRouteData(HttpContextBase httpContext)
  81. {
  82. if (DataSettingsHelper.DatabaseIsInstalled() && this.SeoFriendlyUrlsForLanguagesEnabled)
  83. {
  84. string virtualPath = httpContext.Request.AppRelativeCurrentExecutionFilePath;
  85. string applicationPath = httpContext.Request.ApplicationPath;
  86. if (virtualPath.IsLocalizedUrl(applicationPath, false))
  87. {
  88. //In ASP.NET Development Server, an URL like "http://localhost/Blog.aspx/Categories/BabyFrog" will return
  89. //"~/Blog.aspx/Categories/BabyFrog" as AppRelativeCurrentExecutionFilePath.
  90. //However, in II6, the AppRelativeCurrentExecutionFilePath is "~/Blog.aspx"
  91. //It seems that IIS6 think we're process Blog.aspx page.
  92. //So, I'll use RawUrl to re-create an AppRelativeCurrentExecutionFilePath like ASP.NET Development Server.
  93.  
  94. //Question: should we do path rewriting right here?
  95. string rawUrl = httpContext.Request.RawUrl;
  96. var newVirtualPath = rawUrl.RemoveLanguageSeoCodeFromRawUrl(applicationPath);
  97. if (string.IsNullOrEmpty(newVirtualPath))
  98. newVirtualPath = "/";
  99. newVirtualPath = newVirtualPath.RemoveApplicationPathFromRawUrl(applicationPath);
  100. newVirtualPath = "~" + newVirtualPath;
  101. httpContext.RewritePath(newVirtualPath, true);
  102. }
  103. }
  104. RouteData data = base.GetRouteData(httpContext);
  105. return data;
  106. }
  107.  
  108. /// <summary>
  109. /// Returns information about the URL that is associated with the route.
  110. /// </summary>
  111. /// <param name="requestContext">An object that encapsulates information about the requested route.</param>
  112. /// <param name="values">An object that contains the parameters for a route.</param>
  113. /// <returns>
  114. /// An object that contains information about the URL that is associated with the route.
  115. /// </returns>
  116. public override VirtualPathData GetVirtualPath(RequestContext requestContext, RouteValueDictionary values)
  117. {
  118. VirtualPathData data = base.GetVirtualPath(requestContext, values);
  119.  
  120. if (data != null && DataSettingsHelper.DatabaseIsInstalled() && this.SeoFriendlyUrlsForLanguagesEnabled)
  121. {
  122. string rawUrl = requestContext.HttpContext.Request.RawUrl;
  123. string applicationPath = requestContext.HttpContext.Request.ApplicationPath;
  124. if (rawUrl.IsLocalizedUrl(applicationPath, true))
  125. {
  126. data.VirtualPath = string.Concat(rawUrl.GetLanguageSeoCodeFromUrl(applicationPath, true), "/",
  127. data.VirtualPath);
  128. }
  129. }
  130. return data;
  131. }
  132.  
  133. public virtual void ClearSeoFriendlyUrlsCachedValue()
  134. {
  135. _seoFriendlyUrlsForLanguagesEnabled = null;
  136. }
  137.  
  138. #endregion
  139.  
  140. #region Properties
  141.  
  142. protected bool SeoFriendlyUrlsForLanguagesEnabled
  143. {
  144. get
  145. {
  146. if (!_seoFriendlyUrlsForLanguagesEnabled.HasValue)
  147. _seoFriendlyUrlsForLanguagesEnabled = EngineContext.Current.Resolve<LocalizationSettings>().SeoFriendlyUrlsForLanguagesEnabled;
  148.  
  149. return _seoFriendlyUrlsForLanguagesEnabled.Value;
  150. }
  151. }
  152.  
  153. #endregion
  154. }
  155. }
  1. using System.Runtime.CompilerServices;
  2.  
  3. namespace System.Web.Routing
  4. {
  5. //
  6. // 摘要:
  7. // 提供用于定义路由及获取路由相关信息的属性和方法。
  8. [TypeForwardedFrom("System.Web.Routing, Version=3.5.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35")]
  9. public class Route : RouteBase
  10. {
  11. //
  12. // 摘要:
  13. // 使用指定的 URL 模式和处理程序类初始化 System.Web.Routing.Route 类的新实例。
  14. //
  15. // 参数:
  16. // url:
  17. // 路由的 URL 模式。
  18. //
  19. // routeHandler:
  20. // 处理路由请求的对象。
  21. public Route(string url, IRouteHandler routeHandler);
  22. //
  23. // 摘要:
  24. // 使用指定的 URL 模式、默认参数值和处理程序类初始化 System.Web.Routing.Route 类的新实例。
  25. //
  26. // 参数:
  27. // url:
  28. // 路由的 URL 模式。
  29. //
  30. // defaults:
  31. // 用于 URL 中缺失的任何参数的值。
  32. //
  33. // routeHandler:
  34. // 处理路由请求的对象。
  35. public Route(string url, RouteValueDictionary defaults, IRouteHandler routeHandler);
  36. //
  37. // 摘要:
  38. // 使用指定的 URL 模式、默认参数值、约束和处理程序类初始化 System.Web.Routing.Route 类的新实例。
  39. //
  40. // 参数:
  41. // url:
  42. // 路由的 URL 模式。
  43. //
  44. // defaults:
  45. // 要在 URL 不包含所有参数时使用的值。
  46. //
  47. // constraints:
  48. // 一个用于指定 URL 参数的有效值的正则表达式。
  49. //
  50. // routeHandler:
  51. // 处理路由请求的对象。
  52. public Route(string url, RouteValueDictionary defaults, RouteValueDictionary constraints, IRouteHandler routeHandler);
  53. //
  54. // 摘要:
  55. // 使用指定的 URL 模式、默认参数值、约束、自定义值和处理程序类初始化 System.Web.Routing.Route 类的新实例。
  56. //
  57. // 参数:
  58. // url:
  59. // 路由的 URL 模式。
  60. //
  61. // defaults:
  62. // 要在 URL 不包含所有参数时使用的值。
  63. //
  64. // constraints:
  65. // 一个用于指定 URL 参数的有效值的正则表达式。
  66. //
  67. // dataTokens:
  68. // 传递到路由处理程序但未用于确定该路由是否匹配特定 URL 模式的自定义值。 这些值会传递到路由处理程序,以便用于处理请求。
  69. //
  70. // routeHandler:
  71. // 处理路由请求的对象。
  72. public Route(string url, RouteValueDictionary defaults, RouteValueDictionary constraints, RouteValueDictionary dataTokens, IRouteHandler routeHandler);
  73.  
  74. //
  75. // 摘要:
  76. // 获取或设置为 URL 参数指定有效值的表达式的词典。
  77. //
  78. // 返回结果:
  79. // 一个包含参数名称和表达式的对象。
  80. public RouteValueDictionary Constraints { get; set; }
  81. //
  82. // 摘要:
  83. // 获取或设置传递到路由处理程序但未用于确定该路由是否匹配 URL 模式的自定义值。
  84. //
  85. // 返回结果:
  86. // 一个包含自定义值的对象。
  87. public RouteValueDictionary DataTokens { get; set; }
  88. //
  89. // 摘要:
  90. // 获取或设置要在 URL 不包含所有参数时使用的值。
  91. //
  92. // 返回结果:
  93. // 一个包含参数名称和默认值的对象。
  94. public RouteValueDictionary Defaults { get; set; }
  95. //
  96. // 摘要:
  97. // 获取或设置处理路由请求的对象。
  98. //
  99. // 返回结果:
  100. // 处理请求的对象。
  101. public IRouteHandler RouteHandler { get; set; }
  102. //
  103. // 摘要:
  104. // 获取或设置路由的 URL 模式。
  105. //
  106. // 返回结果:
  107. // 用于匹配路由和 URL 的模式。
  108. //
  109. // 异常:
  110. // T:System.ArgumentException:
  111. // 以下任一值: 以 ~ 或 / 开头的值。 包含 ? 字符的值。 “全部捕捉”参数不在末尾。
  112. //
  113. // T:System.Exception:
  114. // 没有使用分隔符或文字常量分隔 URL 分段。
  115. public string Url { get; set; }
  116.  
  117. //
  118. // 摘要:
  119. // 返回有关所请求路由的信息。
  120. //
  121. // 参数:
  122. // httpContext:
  123. // 一个对象,封装有关 HTTP 请求的信息。
  124. //
  125. // 返回结果:
  126. // 一个对象,其中包含路由定义中的值。
  127. public override RouteData GetRouteData(HttpContextBase httpContext);
  128. //
  129. // 摘要:
  130. // 返回与路由关联的 URL 的相关信息。
  131. //
  132. // 参数:
  133. // requestContext:
  134. // 一个对象,封装有关所请求的路由的信息。
  135. //
  136. // values:
  137. // 一个包含路由参数的对象。
  138. //
  139. // 返回结果:
  140. // 一个包含与路由关联的 URL 的相关信息的对象。
  141. public override VirtualPathData GetVirtualPath(RequestContext requestContext, RouteValueDictionary values);
  142. //
  143. // 摘要:
  144. // 确定参数值是否与该参数的约束匹配。
  145. //
  146. // 参数:
  147. // httpContext:
  148. // 一个对象,封装有关 HTTP 请求的信息。
  149. //
  150. // constraint:
  151. // 用于测试 parameterName 的正则表达式或对象。
  152. //
  153. // parameterName:
  154. // 要测试的参数的名称。
  155. //
  156. // values:
  157. // 要测试的值。
  158. //
  159. // routeDirection:
  160. // 一个指定 URL 路由是否处理传入请求或构造 URL 的值。
  161. //
  162. // 返回结果:
  163. // 如果参数值与约束匹配,则为 true;否则为 false。
  164. //
  165. // 异常:
  166. // T:System.InvalidOperationException:
  167. // constraint 不是包含正则表达式的字符串。
  168. protected virtual bool ProcessConstraint(HttpContextBase httpContext, object constraint, string parameterName, RouteValueDictionary values, RouteDirection routeDirection);
  169. }
  170. }
  1. using System;
  2. using System.Web.Mvc;
  3. using System.Web.Routing;
  4.  
  5. namespace Nop.Web.Framework.Seo
  6. {
  7. public static class GenericPathRouteExtensions
  8. {
  9. //Override for localized route
  10. public static Route MapGenericPathRoute(this RouteCollection routes, string name, string url)
  11. {
  12. return MapGenericPathRoute(routes, name, url, null /* defaults */, (object)null /* constraints */);
  13. }
  14. public static Route MapGenericPathRoute(this RouteCollection routes, string name, string url, object defaults)
  15. {
  16. return MapGenericPathRoute(routes, name, url, defaults, (object)null /* constraints */);
  17. }
  18. public static Route MapGenericPathRoute(this RouteCollection routes, string name, string url, object defaults, object constraints)
  19. {
  20. return MapGenericPathRoute(routes, name, url, defaults, constraints, null /* namespaces */);
  21. }
  22. public static Route MapGenericPathRoute(this RouteCollection routes, string name, string url, string[] namespaces)
  23. {
  24. return MapGenericPathRoute(routes, name, url, null /* defaults */, null /* constraints */, namespaces);
  25. }
  26. public static Route MapGenericPathRoute(this RouteCollection routes, string name, string url, object defaults, string[] namespaces)
  27. {
  28. return MapGenericPathRoute(routes, name, url, defaults, null /* constraints */, namespaces);
  29. }
  30. public static Route MapGenericPathRoute(this RouteCollection routes, string name, string url, object defaults, object constraints, string[] namespaces)
  31. {
  32. if (routes == null)
  33. {
  34. throw new ArgumentNullException("routes");
  35. }
  36. if (url == null)
  37. {
  38. throw new ArgumentNullException("url");
  39. }
  40.  
  41. var route = new GenericPathRoute(url, new MvcRouteHandler())
  42. {
  43. Defaults = new RouteValueDictionary(defaults),
  44. Constraints = new RouteValueDictionary(constraints),
  45. DataTokens = new RouteValueDictionary()
  46. };
  47.  
  48. if ((namespaces != null) && (namespaces.Length > ))
  49. {
  50. route.DataTokens["Namespaces"] = namespaces;
  51. }
  52.  
  53. routes.Add(name, route);
  54.  
  55. return route;
  56. }
  57. }
  58. }

NopCommerce Url分析的更多相关文章

  1. NopCommerce架构分析(转载)

    原文 一,NopCommerce架构分析之开篇 NopCommerce是.net开源项目中比较成熟的一款业务应用框架,也是电子商务系统中的典范.所以很想多学习一下里面的设计和实现方式. 二,NopCo ...

  2. 在线恶意软件和URL分析集成框架 – MalSub

    malsub是一个基于Python 3.6.x的框架,它的设计遵循了当前最流行的互联网软件架构RESTful架构,并通过其RESTful API应用程序编程接口(API),封装了多个在线恶意软件和UR ...

  3. NopCommerce源代码分析之用户验证和权限管理

    目录 1.  介绍 2.  UML 2.1  实体类UML图 2.2  业务相关UML图 3.  核心代码分析 3.1  实体类源代码 3.2  业务相关源代码 3.3  相关控制器源代码 3.4  ...

  4. Javascript 利用a标签自动解析URL分析网址实例

    /* * @function: 通过a标签解析url标签 * @param:url url参数是字符串,解析的目标 通过IE6-9 chrome Firefox测试 * */ function par ...

  5. NopCommerce架构分析之六------自定义RazorViewEngine

    系统中对Razor的支持包括两部分,其中之一就是自定义RazorViewEngine 一.自定义RazorViewEngine 在Global.asax.cs的Application_Start方法中 ...

  6. NopCommerce架构分析之三---数据库初试化及数据操作

    系统启动时执行任务:IStartupTask,启动时执行的任务主要是数据库的初始化和加载. IStartupTask调用IEfDataProvider进行数据库的初始化. IEfDataProvide ...

  7. NopCommerce架构分析之四----插件机制

    NopCommerce支持灵活的插件机制,所谓Web系统插件,其实也就是可以像原系统的一部分一样使用. Web系统的使用方式就是客户端发送一个请求,服务端进行解析.在asp.net MVC中对客户请求 ...

  8. NopCommerce架构分析之一----依赖类生成容器

    NopCommerce为了实现松耦合的框架设计目的,使用了IOC框架:Autofac.据有人测试,Autofac是性能好的IOC工具. 1.在IOC中,组件首先需要在IOC中注册,有通过配置文件注册的 ...

  9. nopCommerce架构分析系列(二)数据Cache

    原文(http://www.cnblogs.com/gusixing/archive/2012/04/12/2443799.html)非常感谢作者顾思行的分享! 序言 在很多访问量较大的系统中,尤其在 ...

随机推荐

  1. Entity Framework Code First (八)迁移 Migrations

    创建初始模型和数据库 在开始使用迁移(Migrations)之前,我们需要一个 Project 和一个 Code First Model, 对于本文将使用典型的 Blog 和 Post 模型 创建一个 ...

  2. ubuntu15.10下搭建cordova+ionic开发环境

    安装jdk 在命令下输入java如果没有安装会提示该命令包含于openjdk软件包 sudo apt-get install openjdk然后按下tab会列出openjdk开头的软件包 我这里就选择 ...

  3. mysql-数据类型与java数据类型转化工具类

    mysql和java对照表 类型名称 显示长度 数据库类型 JAVA类型 JDBC类型索引(int) 描述             VARCHAR L+N VARCHAR java.lang.Stri ...

  4. MVVM: 通过 x:Bind 实现 MVVM(不用 Command)

    背水一战 Windows 10 之 MVVM(Model-View-ViewModel) 通过 x:Bind 实现 MVVM(不用 Command) 示例1.ModelMVVM/Model/Produ ...

  5. 「个人vim插件+配置」

    2016.10.4 filetype indent on syntax on set nu ai ci si set sw= ts= set autochdir set backspace= colo ...

  6. Quality Trimming Via Trimmomatic

    已经去除接头(adapter) java -jar trimmomatic.jar PE -threads 20 -phred33 \ left.fastq.gz right.fastq.gz \ l ...

  7. GraphX 的属性图

    package main.scala import org.apache.spark.graphx.{Edge, Graph, VertexId} import org.apache.spark.rd ...

  8. 【BZOJ-4631】踩气球 线段树 + STL

    4631: 踩气球 Time Limit: 10 Sec  Memory Limit: 256 MBSubmit: 224  Solved: 114[Submit][Status][Discuss] ...

  9. macOS安装「oh my zsh」

    目前常用的 Linux 系统和 OS X 系统的默认 Shell 都是 bash,但是真正强大的 Shell 是深藏不露的 zsh, 这货绝对是马车中的跑车,跑车中的飞行车,史称『终极 Shell』, ...

  10. GitHub Pages和每个项目绑定自定义域名(支持多个和顶级域名)

    假设我购买的域名为www.easonjim.com,想把www.easonjim.com和easonjim.com的域名跳转到下面的网址easonjim.github.io. 而我在github上的账 ...