当前位置: 首页>>代码示例>>C#>>正文


C# UrlHelper.UserProfileUrl方法代码示例

本文整理汇总了C#中System.Web.Mvc.UrlHelper.UserProfileUrl方法的典型用法代码示例。如果您正苦于以下问题:C# UrlHelper.UserProfileUrl方法的具体用法?C# UrlHelper.UserProfileUrl怎么用?C# UrlHelper.UserProfileUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.Mvc.UrlHelper的用法示例。


在下文中一共展示了UrlHelper.UserProfileUrl方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GenerateXml

		/// <summary>
		/// Generates the Xml Sitemap
		/// </summary>
		/// <param name="urlHelper"> </param>
		public string GenerateXml(UrlHelper urlHelper)
		{
			var xml = new StringBuilder();

			xml.AppendLine("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
			xml.Append("<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\" " + 
				"xmlns:image=\"http://www.sitemaps.org/schemas/sitemap-image/1.1\" " +
				"xmlns:video=\"http://www.sitemaps.org/schemas/sitemap-video/1.1\">");
			xml.AppendLine();

			#region STATIC LINKS 

			// Add the Static Links
			StaticLinks.ForEach(x => xml.AppendLine(this.CreateUrlString(x, new DateTime(2012, 08, 14), "weekly")));

			#endregion

			#region STYLES

			// Add the Recipe Style Detail Page Links
			var styles = this.BeerStyleService.GetStyleSummaries();

			foreach(var style in styles)
			{
				xml.AppendLine(this.CreateUrlString(urlHelper.StyleDetailUrl(style.UrlFriendlyName), DateTime.Now, "daily", "1.0"));

				var stylePageCount = this.BeerStyleService.GetStylePageCount(style.SubCategoryId);

				for(var page = 2; page <= stylePageCount; page++)
				{
					xml.AppendLine(this.CreateUrlString(urlHelper.StyleDetailUrl(style.UrlFriendlyName, page), DateTime.Now, "daily", "1.0"));
				}
			}

			#endregion

			#region UNCATEGORIZED 

			// Add the Uncategorized Pages
			//http://dev.brewgr.com/recipes/other-homebrew-recipes
			var uncategorizedPageCount = this.BeerStyleService.GetUnCategorizedRecipesPageCount();

			if(uncategorizedPageCount > 0)
			{
				xml.AppendLine(this.CreateUrlString(urlHelper.Action("other-homebrew-recipes", "Recipe", new { page = (int?)null }, "http"), DateTime.Now, "daily", "1.0"));
				if(uncategorizedPageCount > 1)
				{
					for(var page = 2; page <= uncategorizedPageCount; page++)
					{
						xml.AppendLine(this.CreateUrlString(urlHelper.Action("other-homebrew-recipes", "Recipe", new { page = page }, "http"), DateTime.Now, "daily", "1.0"));
					}
				}
			}

			#endregion

			#region RECIPE DETAIL 

			// Add the Recipe Links (this will need to be extracted when we hit thousands of Recipes)
			var recipes = this.RecipeService.GetAllRecipes();
			recipes.ForEach(x => xml.AppendLine(this.CreateUrlString(urlHelper.RecipeDetailUrl(x.RecipeId, x.RecipeName, (x.BjcpStyle != null ? x.BjcpStyle.SubCategoryName : null)), x.DateModified ?? x.DateCreated, "weekly", "1.0")));

			#endregion

			#region BREW SESSION DETAIL 

			var brewSessions = this.RecipeService.GetAllBrewSessionSummaries();
			brewSessions.ForEach(x => xml.AppendLine(this.CreateUrlString(urlHelper.BrewSessionDetailUrl(x.BrewSessionId, x.RecipeName), x.DateModified ?? x.DateCreated, "weekly", "1.0")));

			#endregion

			#region USER PROFILES

			// Add the User Profile Links (this will need to be extracted when we have a lot of users)
			var users = this.UserService.GetAllUsers();
			users.ForEach(x => xml.AppendLine(this.CreateUrlString(urlHelper.UserProfileUrl(x.CalculatedUsername), x.DateModified ?? x.DateCreated, "weekly", "0.6")));

			#endregion

			xml.Append("</urlset>");

			return xml.ToString();
		}
开发者ID:AnthonyYates,项目名称:brewgr.com,代码行数:87,代码来源:BrewgrSeoSitemap.cs


注:本文中的System.Web.Mvc.UrlHelper.UserProfileUrl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。