ASP.NET MVC路由扩展:链接和URL的生成(3)

来源:未知 责任编辑:责任编辑 发表时间:2014-02-02 17:48 点击:

   6:     public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, string controllerName);
   7:     public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, RouteValueDictionary routeValues);
   8:     public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, object routeValues, object htmlAttributes);
   9:     public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, RouteValueDictionary routeValues, IDictionary<string, object> htmlAttributes);
  10:     public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, string controllerName, object routeValues, object htmlAttributes);
  11:     public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, string controllerName,RouteValueDictionary routeValues, IDictionary<string, object> htmlAttributes);
  12:     public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, string controllerName, string protocol, string hostName, string fragment, object routeValues, object htmlAttributes);
  13:     public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, string controllerName, string protocol, string hostName, string fragment, RouteValueDictionary routeValues, IDictionary<string, object> htmlAttributes);  
  14: }

三、实例演示:创建一个RouteHelper模拟UrlHelper的URL生成逻辑
为了让读者对UrlHelper如果利用ASP.NET路由系统进行URL生成的逻辑具有一个深刻认识,我们接下来创建一个名为RouteHelper的等效帮助类。我们将RouteHelper定义在创建的一个ASP.NET Web应用中,如下面的代码片断所示,RouteHelper具有RequestContext和RouteCollection两个属性,前者在构造函数中指定,后者则只是使用通过RouteTable的Routes静态属性表示的全局路由表。源代码从这里下载。
   1: public class RouteHelper
   2: {
   3:     public RequestContext RequestContext { get; private set; }
   4:     public RouteCollection RouteCollection { get; private set; }
   5:     public RouteHelper(RequestContext requestContext)
   6:     {
   7:         this.RequestContext = requestContext;
   8:         this.RouteCollection = RouteTable.Routes;
   9:     }
  10: 
  11:     public string Action(string actionName)

发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
用户名: 验证码:点击我更换图片
最新评论 更多>>

推荐热点

  • 浅析.NET下XML数据访问新机制
  • asp.net 面试+笔试题目第1/2页
  • C# 邮件地址是否合法的验证
  • asp.net 设置GridView的选中行的实现代码
  • C#高级编程:数据库连接[1]
  • 经典C++程序1
  • IIS 自动回收导致后台定时器失效的问题解决
  • ASP.NET&#160;GridView列表代码示例
  • Asp.net MVC源码分析--Action Filter的链式调用
网站首页 - 友情链接 - 网站地图 - TAG标签 - RSS订阅 - 内容搜索
Copyright © 2008-2015 计算机技术学习交流网. 版权所有

豫ICP备11007008号-1