本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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;
}
示例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));
}
示例6: ActionLink
public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, ActionResult result) {
return htmlHelper.RouteLink(linkText, result.GetRouteValueDictionary());
}
示例7: Action
public static string Action(this UrlHelper urlHelper, ActionResult result) {
return urlHelper.RouteUrl(null, result.GetRouteValueDictionary());
}
示例8: ActionLink
public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, ActionResult result, IDictionary<string, object> htmlAttributes) {
return htmlHelper.RouteLink(linkText, result.GetRouteValueDictionary(), htmlAttributes);
}
示例9: TransferToAction
public static TransferToRouteResult TransferToAction(this Controller controller, ActionResult result)
{
return new TransferToRouteResult(result.GetRouteValueDictionary());
}
示例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;
}
示例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));
}
示例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);
}
示例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);
}
示例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));
}
示例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;
}