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


C# ActionResult.GetRouteValueDictionary方法代码示例

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


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

示例1: GetUrl

 public static string GetUrl(this HtmlHelper html, ActionResult actionResult)
 {
     if (actionResult == null) throw new ArgumentNullException("actionResult");
     RouteValueDictionary routeValueDictionary = actionResult.GetRouteValueDictionary();
     return UrlHelper.GenerateUrl(null, null, null, routeValueDictionary, html.RouteCollection,
                           html.ViewContext.RequestContext, false);
 }
开发者ID:madaboutcode,项目名称:Chronicles,代码行数:7,代码来源:HtmlHelperExtensions.cs

示例2: NavImageLink

 public static string NavImageLink(this HtmlHelper helper, string linkText, string imageTag, ActionResult action)
 {
     var urlHelper = new UrlHelper(helper.ViewContext.RequestContext, helper.RouteCollection);
     var tagBuilder = new TagBuilder("a");
     tagBuilder.MergeAttribute("href", urlHelper.RouteUrl(action.GetRouteValueDictionary()));
     tagBuilder.InnerHtml = helper.ImgFor(imageTag) + linkText;
     return tagBuilder.ToString(TagRenderMode.Normal);
 }
开发者ID:gosuto,项目名称:tfs2.com,代码行数:8,代码来源:ImageLinkExtensions.cs

示例3: IsActive

        public static MvcHtmlString IsActive(this HtmlHelper helper, ActionResult action)
        {
            RouteValueDictionary dic = action.GetRouteValueDictionary();
            var actionName = dic["Action"].ToString();
            var controllerName = dic["Controller"].ToString();
            var currentAction = helper.ViewContext.RouteData.Values["Action"].ToString();
            var currentController = helper.ViewContext.RouteData.Values["Controller"].ToString();
            var rslt = string.Equals(actionName, currentAction, StringComparison.OrdinalIgnoreCase) && string.Equals(controllerName, currentController, StringComparison.OrdinalIgnoreCase);

            return rslt ? new MvcHtmlString(@" class=""active "" ") : new MvcHtmlString(string.Empty);
        }
开发者ID:RytisCapas,项目名称:InventoryManagement,代码行数:11,代码来源:IsActiveExtension.cs

示例4: MapRoute

        public static Route MapRoute(this RouteCollection routes, string name, string url, ActionResult result, object defaults) {
            // Start by adding the default values from the anonymous object (if any)
            var routeValues = new RouteValueDictionary(defaults);

            // Then add the Controller/Action names and the parameters from the call
            foreach (var pair in result.GetRouteValueDictionary()) {
                routeValues.Add(pair.Key, pair.Value);
            }

            // Create and add the route
            var route = new Route(url, routeValues, new MvcRouteHandler());
            routes.Add(name, route);
            return route;
        }
开发者ID:gmstr,项目名称:GMSBlog,代码行数:14,代码来源:T4MVC.cs

示例5: ActionLink

 public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, ActionResult result, object htmlAttributes, string protocol = null, string hostName = null, string fragment = null) {
     return htmlHelper.RouteLink(linkText, null, protocol ?? result.GetT4MVCResult().Protocol, hostName, fragment, result.GetRouteValueDictionary(), HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes));
 }
开发者ID:IanFelton,项目名称:WeNeedUHave,代码行数:3,代码来源:T4MVC.cs

示例6: ActionLink

 public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, ActionResult result) {
     return htmlHelper.RouteLink(linkText, result.GetRouteValueDictionary());
 }
开发者ID:veraveramanolo,项目名称:power-show,代码行数:3,代码来源:T4MVC.cs

示例7: Action

 public static string Action(this UrlHelper urlHelper, ActionResult result) {
     return urlHelper.RouteUrl(null, result.GetRouteValueDictionary());
 }
开发者ID:ilivewithian,项目名称:Raven-Product-Search,代码行数:3,代码来源:T4MVC.cs

示例8: ActionLink

 public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, ActionResult result, IDictionary<string, object> htmlAttributes) {
     return htmlHelper.RouteLink(linkText, result.GetRouteValueDictionary(), htmlAttributes);
 }
开发者ID:Gutek,项目名称:Library,代码行数:3,代码来源:T4MVC.cs

示例9: TransferToAction

 public static TransferToRouteResult TransferToAction(this Controller controller, ActionResult result)
 {
     return new TransferToRouteResult(result.GetRouteValueDictionary());
 }
开发者ID:alexidsa,项目名称:civildoit,代码行数:4,代码来源:ControllerExtensions.cs

示例10: CreateRoute

        private static Route CreateRoute(string url, ActionResult result, object defaults, object constraints, string[] namespaces)
        {
            // Start by adding the default values from the anonymous object (if any)
            var routeValues = new RouteValueDictionary(defaults);

            // Then add the Controller/Action names and the parameters from the call
            foreach (var pair in result.GetRouteValueDictionary())
            {
                routeValues.Add(pair.Key, pair.Value);
            }

            var routeConstraints = new RouteValueDictionary(constraints);

            // Create and add the route
            var route = new Route(url, routeValues, routeConstraints, new MvcRouteHandler());

            route.DataTokens = new RouteValueDictionary();

            if (namespaces != null && namespaces.Length > 0)
            {
                route.DataTokens["Namespaces"] = namespaces;
            }

            return route;
        }
开发者ID:shahr00z,项目名称:TavanTarkhis,代码行数:25,代码来源:T4MVC.cs

示例11: ActionLink

 public static MvcHtmlString ActionLink(this AjaxHelper ajaxHelper, string linkText, ActionResult result, AjaxOptions ajaxOptions, object htmlAttributes)
 {
     return ajaxHelper.RouteLink(linkText, result.GetRouteValueDictionary(), ajaxOptions, HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes));
 }
开发者ID:shahr00z,项目名称:TavanTarkhis,代码行数:4,代码来源:T4MVC.cs

示例12: JavaScriptReplaceableUrl

        /// <summary>
        /// If specific route can be found, return that route with the parameter tokens in route string.
        /// </summary>
        public static string JavaScriptReplaceableUrl(this UrlHelper urlHelper, ActionResult result)
        {
            var rvd = result.GetRouteValueDictionary();
            string area = string.Empty;
            object token;

            if (rvd.TryGetValue("area", out token))
                area = token.ToString();

            if (!rvd.TryGetValue("controller", out token))
                throw new Exception("T4MVC JavascriptReplacableUrl could not locate controller in source dictionary");
            string controller = token.ToString();

            if (!rvd.TryGetValue("SecureAction", out token))
                throw new Exception("T4MVC JavascriptReplacableUrl could not locate SecureAction in source dictionary");
            string SecureAction = token.ToString();

            // This matches the ActionResult to a specific route (so we can get the exact URL)
            string specificSecureActionUrl = RouteTable.Routes.OfType<Route>()
                .Where(r => r.DataTokens.CompareValue("area", area)
                    && r.Defaults.CompareValue("controller", controller)
                    && r.Defaults.CompareValue("SecureAction", SecureAction))
                .Select(r => r.Url)
                .FirstOrDefault();

            if (String.IsNullOrEmpty(specificSecureActionUrl))
            {
                return urlHelper.RouteUrl(null, result.GetRouteValueDictionary());
            }

            return urlHelper.Content("~/" + specificSecureActionUrl);
        }
开发者ID:rabbal,项目名称:Decision,代码行数:35,代码来源:T4SecureExtensions.cs

示例13: SecureBeginRouteForm

 public static MvcForm SecureBeginRouteForm(this HtmlHelper htmlHelper, string routeName, ActionResult result, FormMethod method, IDictionary<string, object> htmlAttributes)
 {
     return htmlHelper.BeginRouteForm(routeName, result.GetRouteValueDictionary(), method, htmlAttributes);
 }
开发者ID:rabbal,项目名称:Decision,代码行数:4,代码来源:T4SecureExtensions.cs

示例14: ActionLink

 public static string ActionLink(this AjaxHelper ajaxHelper, string linkText, ActionResult result, AjaxOptions ajaxOptions, object htmlAttributes) {
     return ajaxHelper.RouteLink(linkText, result.GetRouteValueDictionary(), ajaxOptions, new RouteValueDictionary(htmlAttributes));
 }
开发者ID:gmstr,项目名称:GMSBlog,代码行数:3,代码来源:T4MVC.cs

示例15: ResolveUrl

        public static string ResolveUrl(this ControllerContext context, ActionResult result)
        {
            var logger = ObjectFactory.GetInstance<Logger>();

            if (context == null)
            {
                logger.Error("[Extensions].[ControllerContextExtensions].[ResolveUrl(ControllerContext, ActionResult)] throwing exception ([context] == null).");
                throw new ArgumentNullException("context");
            }

            if (result == null)
            {
                logger.Error("[Extensions].[ControllerContextExtensions].[ResolveUrl(ControllerContext, ActionResult)] throwing exception ([result] == null).");
                throw new ArgumentNullException("result");
            }

            return RouteTable.Routes.GetVirtualPath(context.RequestContext, result.GetRouteValueDictionary()).VirtualPath;
        }
开发者ID:vitalyobukhov,项目名称:SmsToMail,代码行数:18,代码来源:ControllerContextExtensions.cs


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