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


C# RouteValueDictionary.Add方法代码示例

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


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

示例1: SearchTabsPost

        public ActionResult SearchTabsPost(TabsViewModel viewModel)
        {
            var dic = new RouteValueDictionary()
                          {
                              {"tabkey", viewModel.TabKey},
                              {"tabid", viewModel.TabId},
                              {"MetalFilter", viewModel.MetalFilter},
                              {"OrderByPrice", viewModel.OrderByPrice},
                              {"itemsperpage", viewModel.ItemsPerPage}

                          };

            var counter = 0;
            if (viewModel.CustomFilters != null)
            {
                foreach (var filterValue in viewModel.CustomFilters)
                {
                    //TODO do tis strongly typed with reflaction
                    dic.Add("CustomFilters" + "[" + counter.ToString() + "].Value", filterValue.Value);
                    dic.Add("CustomFilters" + "[" + counter.ToString() + "].Name", filterValue.Name);
                    counter++;
                }
                dic.Add("page", 1);
            }
            else
            {
                dic.Add("page",viewModel.Page);
            }

            return RedirectToRoute("Tabs",dic );
        }
开发者ID:mamluka,项目名称:JewelryONet,代码行数:31,代码来源:TabsController.cs

示例2: CreateRouteConstraints

        private RouteValueDictionary CreateRouteConstraints(RouteSpecification routeSpec)
        {
            var constraints = new RouteValueDictionary();

            // Default constraints
            constraints.Add("httpMethod", new RestfulHttpMethodConstraint(routeSpec.HttpMethod));

            // Attribute-based constraints
            foreach (var constraintAttribute in routeSpec.ConstraintAttributes.Where(c => !constraints.ContainsKey(c.Key)))
                constraints.Add(constraintAttribute.Key, constraintAttribute.Constraint);

            var detokenizedUrl = DetokenizeUrl(CreateRouteUrl(routeSpec));
            var urlParameterNames = GetUrlParameterNames(detokenizedUrl);

            // Convention-based constraints
            foreach (var defaultConstraint in _configuration.DefaultRouteConstraints)
            {
                var pattern = defaultConstraint.Key;
                var matchedUrlParameterNames = urlParameterNames.Where(n => Regex.IsMatch(n, pattern));
                foreach (var urlParameterName in matchedUrlParameterNames.Where(n => !constraints.ContainsKey(n)))
                    constraints.Add(urlParameterName, defaultConstraint.Value);
            }

            return constraints;
        }
开发者ID:mdmoura,项目名称:AttributeRouting,代码行数:25,代码来源:RouteBuilder.cs

示例3: RedirectToTheLoginPage

 private void RedirectToTheLoginPage(ActionExecutedContext filterContext)
 {
     var routeValueDictionary = new RouteValueDictionary();
     routeValueDictionary.Add("controller", "Login");
     routeValueDictionary.Add("action", "Index");
     filterContext.Result = new RedirectToRouteResult(routeValueDictionary);
 }
开发者ID:burkhartt,项目名称:Bennington,代码行数:7,代码来源:RedirectToTheLoginPageIfNotLoggedI.cs

示例4: Application_Start

 void Application_Start(object sender, EventArgs e)
 {
     RouteTable.Routes.RouteExistingFiles = true;
     // 在应用程序启动时运行的代码
     //RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
     RouteValueDictionary defaults = new RouteValueDictionary();
     defaults.Add("name", "张三");
     RouteValueDictionary constraints = new RouteValueDictionary();
     constraints.Add("name",@"[1-10]");
     RouteValueDictionary dataTokens = new RouteValueDictionary();
     dataTokens.Add("age",22);
     dataTokens.Add("httpMethod",new HttpMethodConstraint("GET"));
     RouteTable.Routes.Ignore("Content/{filename}.css/{*pathInfo}");
     //1.
     RouteTable.Routes.MapPageRoute(
         "default",
         "Content/{name}",
         "~/Default.aspx", false, defaults,null,dataTokens
         );
     RouteTable.Routes.MapPageRoute(
     "route2",
     "Route/{age}",
     "~/Default.aspx", false, defaults, null, dataTokens
     );
     //PageRouteHandler pageRou teHandler=new PageRouteHandler(RouteTable.Routes.GetVirtualPath(null,null).VirtualPath);
     //2
     Route route=new Route("Hello/{name}",new PageRouteHandler("~/Default.aspx"));
     //PageRouteHandler  routeHandler=new PageRouteHandler();
     RouteTable.Routes.Add(route);
 }
开发者ID:on-looker,项目名称:DTest,代码行数:31,代码来源:Global.asax.cs

示例5: Create

 private static RouteValueDictionary Create(string action, string controller, object values)
 {
     RouteValueDictionary dict = new RouteValueDictionary(values);
     if(controller != null) dict.Add("controller", controller);
     dict.Add("action", action);
     return dict;
 }
开发者ID:supuy-ruby,项目名称:Aoite,代码行数:7,代码来源:RedirectToActionResult.cs

示例6: MapRoute

		public static void MapRoute(
			this System.Web.Routing.RouteCollection routes ,
			MvcRouteConfigurationSection section ) {
			// Manipulate the Ignore List
			foreach ( IgnoreItem ignoreItem in section.Ignore ) {
				var ignoreConstraints = new RouteValueDictionary();

				foreach ( Constraint constraint in ignoreItem.Constraints ) {
					ignoreConstraints.Add( constraint.Name , constraint.Value );
				}

				IgnoreRoute( routes , ignoreItem.Url , ignoreConstraints );
			}

			// Manipluate the Routing Table
			foreach ( RoutingItem routingItem in section.Map ) {
				var defaults = new RouteValueDictionary();
				var constraints = new RouteValueDictionary();

				if ( routingItem.Controller != string.Empty )
					defaults.Add( "controller" , routingItem.Controller );

				if ( routingItem.Action != string.Empty )
					defaults.Add( "action" , routingItem.Action );

				foreach ( Parameter param in routingItem.Paramaters ) {
					defaults.Add( param.Name , param.Value );
					if ( !string.IsNullOrEmpty( param.Constraint ) )
						constraints.Add( param.Name , param.Constraint );
				}

				MapRoute( routes , routingItem.Name , routingItem.Url , defaults , constraints );
			}
		}
开发者ID:kisflying,项目名称:kion,代码行数:34,代码来源:RouteCollectionExtensions.cs

示例7: OnActionExecuting

        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            if (MySession.CurrentUser == null)
            {
                FormsAuthentication.SignOut();
                RouteValueDictionary redirectTargetDictionary = new RouteValueDictionary();
                redirectTargetDictionary.Add("action", "Index");
                redirectTargetDictionary.Add("controller", "Account");

                filterContext.Result = new RedirectToRouteResult(redirectTargetDictionary);
            }
            else if (MySession.CurrentUser.Type!="AD")
            {
                RouteValueDictionary redirectTargetDictionary = new RouteValueDictionary();
                redirectTargetDictionary.Add("action", "NoAccess");
                redirectTargetDictionary.Add("controller", "Home");

                filterContext.Result = new RedirectToRouteResult(redirectTargetDictionary);

            }else
            {

                base.OnActionExecuting(filterContext);
            }
        }
开发者ID:bneuhold,项目名称:EFQM,代码行数:25,代码来源:Filters.cs

示例8: BatchUpdateGroupAuditStatu

 /// <summary>
 /// 设置群组的审核状态
 /// </summary>
 /// <param name="siteUrls"></param>
 /// <param name="isApproved">是否通过</param>
 /// <returns></returns>
 public static string BatchUpdateGroupAuditStatu(this SiteUrls siteUrls, long groupId, bool isApproved = true)
 {
     RouteValueDictionary routeValueDictionary = new RouteValueDictionary();
     routeValueDictionary.Add("groupId", groupId);
     routeValueDictionary.Add("isApproved", isApproved);
     return CachedUrlHelper.Action("BatchUpdateGroupAuditStatu", "ControlPanelGroup", GroupAreaName, routeValueDictionary);
 }
开发者ID:hbulzy,项目名称:SYS,代码行数:13,代码来源:SiteUrls.cs

示例9: HandleUnauthorizedRequest

        protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext)
        {
            if (filterContext.HttpContext.Request.IsAjaxRequest())
            {
                var urlHelper = new UrlHelper(filterContext.RequestContext);
                filterContext.HttpContext.Response.StatusCode = 403;
                filterContext.Result = new JsonResult
                {
                    Data = new
                    {
                        Error = "NotAuthorized",
                        LogOnUrl = urlHelper.Action("Login", "Account", new { SessionTimeout = true })
                    },
                    JsonRequestBehavior = JsonRequestBehavior.AllowGet
                };
            }
            else
            {
                var routeValues = new RouteValueDictionary();

                routeValues.Add("Controller", "Account");
                routeValues.Add("Action", "Login");
                routeValues.Add("SessionTimeout", true);
                if (filterContext.HttpContext.Request.UrlReferrer != null)
                    routeValues.Add("ReturnUrl", filterContext.HttpContext.Request.UrlReferrer.PathAndQuery);
                filterContext.Result = new RedirectToRouteResult(routeValues);
            }
        }
开发者ID:Burima,项目名称:LYSApp,代码行数:28,代码来源:LYSUserAuthorize.cs

示例10: OnActionExecuting

        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);

            MxUser mxUser = (MxUser)filterContext.HttpContext.Session["User"];
            RouteValueDictionary rvd = new RouteValueDictionary();
            if (mxUser != null)
            {
                if (!BLL.MxLicense.SeatCheck(mxUser.MbrUser.ProviderUserKey.ToString(), filterContext.HttpContext.Session.SessionID))
                {
                    //user has been kicked out and needs to login

                    //clear session
                    filterContext.HttpContext.Session.Clear();
                    FormsAuthentication.SignOut();

                    rvd.Add("msg", "noseat");
                    filterContext.Result = new RedirectToRouteResult("Login", rvd);
                }
            }
            else
            {
                //user is not logged in

                rvd.Add("msg", "session");
                filterContext.Result = new RedirectToRouteResult("Login", rvd);
            }
        }
开发者ID:ManEx,项目名称:WebManex,代码行数:28,代码来源:SeatCheck.cs

示例11: OnException

 protected override void OnException(ExceptionContext filterContext)
 {
     Entity.Monitoring.ExceptionLog exlog = new Entity.Monitoring.ExceptionLog();
     if (Session != null && Session["User"] != null)
         exlog.AccountId = ((Entity.User.Account)Session["User"]).Id;
     exlog.EntityValue = "";
     exlog.Exception = filterContext.Exception.ToString();
     exlog.ExceptionCode = filterContext.Exception.Source;
     exlog.ExceptionMessage = filterContext.Exception.Message;
     exlog.EntityValue = "";
     System.Web.Mvc.Controller _controller = ((System.Web.Mvc.Controller)filterContext.Controller);
     string key = "";
     for (int i = 0; i < _controller.ModelState.Keys.Count; i++)
     {
         key = _controller.ModelState.Keys.ToList()[i];
         exlog.EntityValue += "<" + key + " = ";
         for (int j = 0; j < ((string[])(_controller.ModelState[key].Value.RawValue)).Length; j++)
         {
             exlog.EntityValue += ((string[])(_controller.ModelState[key].Value.RawValue))[j] + " ; ";
         }
         exlog.EntityValue += ">";
     }
     exlog.ExecuteEntity = filterContext.Controller.GetType().Name;
     this.Bll.Monitoring.CreateExceptionLog(exlog);
     //data sonra değiştirilecek
     RouteValueDictionary rd = new RouteValueDictionary();
     rd.Add("controller", "Home");
     rd.Add("action", "Index");
     new RedirectToRouteResult("Default", rd);
 }
开发者ID:hacikaraa,项目名称:Goldepus,代码行数:30,代码来源:BaseController.cs

示例12: GenerateTab

        public string GenerateTab(ref HtmlHelper html, string text, string value)
        {
            var routeDataValues = html.ViewContext.RequestContext.RouteData.Values;

            RouteValueDictionary pageLinkValueDictionary = new RouteValueDictionary { { Param, value } };

            if (html.ViewContext.RequestContext.HttpContext.Request.QueryString["search"] != null)
                pageLinkValueDictionary.Add("search", html.ViewContext.RequestContext.HttpContext.Request.QueryString["search"]);

            if (!pageLinkValueDictionary.ContainsKey("id") && routeDataValues.ContainsKey("id"))
                pageLinkValueDictionary.Add("id", routeDataValues["id"]);

            // To be sure we get the right route, ensure the controller and action are specified.
            if (!pageLinkValueDictionary.ContainsKey("controller") && routeDataValues.ContainsKey("controller"))
                pageLinkValueDictionary.Add("controller", routeDataValues["controller"]);

            if (!pageLinkValueDictionary.ContainsKey("action") && routeDataValues.ContainsKey("action"))
                pageLinkValueDictionary.Add("action", routeDataValues["action"]);

            // 'Render' virtual path.
            var virtualPathForArea = RouteTable.Routes.GetVirtualPathForArea(html.ViewContext.RequestContext, pageLinkValueDictionary);

            if (virtualPathForArea == null)
                return null;

            var stringBuilder = new StringBuilder("<li");

            if (value == CurrentValue)
                stringBuilder.Append(" class=active");

            stringBuilder.AppendFormat("><a href={0}>{1}</a></li>", virtualPathForArea.VirtualPath, text);

            return stringBuilder.ToString();
        }
开发者ID:revolutionaryarts,项目名称:wewillgather,代码行数:34,代码来源:TabHelper.cs

示例13: BuildNavigation

        public static MvcHtmlString BuildNavigation(this HtmlHelper Helper, string activeLinkName, string linkGroupName)
        {
            TagBuilder LinkContainer = new TagBuilder("ul");
            LinkContainer.AddCssClass("nav nav-pills");

            LinkManager.Instance.GetLinks(linkGroupName)
                .ForEach(Lnk =>
                {
                    string routeName = null;
                    var linkItem = new TagBuilder("li");
                    var RouteParams = new RouteValueDictionary(Lnk.RouteParams);

                    if (!string.IsNullOrEmpty(Lnk.Controller))
                        RouteParams.Add("controller", Lnk.Controller);
                    if (!string.IsNullOrEmpty(Lnk.Action))
                        RouteParams.Add("action", Lnk.Action);
                    if (!string.IsNullOrEmpty(Lnk.Area))
                        RouteParams.Add("area", Lnk.Area);

                    if(Lnk.Name == activeLinkName)
                        linkItem.AddCssClass("active");

                    if (Lnk.UseNamedRoute)
                        routeName = Lnk.RouteName;
                    else
                        routeName = "Default";

                    linkItem.InnerHtml = Helper.RouteLink(Lnk.Text, routeName, RouteParams, Lnk.HtmlAttributes).ToString();

                    LinkContainer.InnerHtml += linkItem.ToString();
                });

            return new MvcHtmlString(LinkContainer.ToString());
        }
开发者ID:CoderNumber1,项目名称:Laziton,代码行数:34,代码来源:LinkHelpers.cs

示例14: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            var request = HttpContext.Current.Request;
            var response = HttpContext.Current.Response;
            //1.存在
            //
            name = this.RouteData.Values["name"] as string;
            //string rq = this.RouteData.GetRequiredString("name");
            //string rqlong =this.RouteData.Route.GetRouteData(this.Request.RequestContext.HttpContext).GetRequiredString("name");
            //string tk = this.RouteData.DataTokens["name"] as string;
            //this.Request.RequestContext.RouteData.Values.Add("name1","李四");
            RouteData rd = new RouteData();
            rd.Values.Add("age", 20);
            rd.Values.Add("name", "lifeng");
            RouteValueDictionary rvd = new RouteValueDictionary();
            rvd.Add("name", "values");
            rvd.Add("age",12);
            RequestContext requestContext = new RequestContext();
            requestContext.HttpContext = new HttpContextWrapper(HttpContext.Current);
            requestContext.RouteData = rd;
            var p1 = RouteTable.Routes.GetVirtualPath(null, null);
            var p2 = RouteTable.Routes.GetVirtualPath(null, rvd);           //Content/values?age=12
            var p3 = RouteTable.Routes.GetVirtualPath(requestContext, null);// Content/values?age=20
            var p4 = RouteTable.Routes.GetVirtualPath(requestContext, rvd);//  Content/values?age=12
            var p5 = RouteTable.Routes.GetVirtualPath(Request.RequestContext, null);// 当前访问路径为Content/Site的时候:Content/Site

            RouteValueDictionary ra = new RouteValueDictionary();
            ra.Add("age",18);
            var p6 = RouteTable.Routes.GetVirtualPath(null, ra);
            var p7 = RouteTable.Routes.GetVirtualPath(requestContext, "route2", rvd);
        }
开发者ID:on-looker,项目名称:DTest,代码行数:31,代码来源:Default.aspx.cs

示例15: ReturnRoute

 public ActionResult ReturnRoute(int? id, ActionResult defaultRoute)
 {
     RouteValueDictionary routeValues = new RouteValueDictionary();
     switch (GetRouteParameter())
     {
         case "c-tls":
             routeValues["controller"] = "Conference";
             routeValues["action"] = "TracksLocationsSlots";
             routeValues.Add("conferenceId", id);
             return Redirect(ModuleRoutingProvider.Instance().GenerateUrl(routeValues, ModuleContext));
         case "c-ss":
             routeValues["controller"] = "Conference";
             routeValues["action"] = "SessionsSpeakers";
             routeValues.Add("conferenceId", id);
             return Redirect(ModuleRoutingProvider.Instance().GenerateUrl(routeValues, ModuleContext));
         case "c-m":
             routeValues["controller"] = "Conference";
             routeValues["action"] = "Manage";
             routeValues.Add("conferenceId", id);
             return Redirect(ModuleRoutingProvider.Instance().GenerateUrl(routeValues, ModuleContext));
         case "s-v":
             routeValues["controller"] = "Session";
             routeValues["action"] = "View";
             routeValues.Add("conferenceId", ControllerContext.HttpContext.Request.Params["ConferenceId"]);
             routeValues.Add("SessionId", id);
             return Redirect(ModuleRoutingProvider.Instance().GenerateUrl(routeValues, ModuleContext));
     }
     return defaultRoute;
 }
开发者ID:EPTamminga,项目名称:Conference,代码行数:29,代码来源:ConferenceMvcController.cs


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