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


C# Controller.Redirect方法代码示例

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


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

示例1: PerformActionProcess

		protected override void PerformActionProcess(Controller controller)
		{
			object instance = null;
			
			try
			{
				AssertIsPost(controller);
				
				instance = binder.BindObject(Model.Type, Model.Type.Name, builder.BuildSourceNode(controller.Request.Form));

				CommonOperationUtils.SaveInstance(instance, controller, errors, ref prop2Validation, false);

				SessionScope.Current.Flush();
				
				if (UseModelName)
				{
					controller.Redirect(controller.AreaName, controller.Name, "list" + Model.Type.Name);
				}
				else
				{
					controller.Redirect(controller.AreaName, controller.Name, "list");
				}
			}
			catch(Exception ex)
			{
				errors.Add("Could not save " + Model.Type.Name + ". " + ex.Message);
			}

			if (errors.Count != 0)
			{
				controller.Context.Flash[Model.Type.Name] = instance;
				controller.Context.Flash["errors"] = errors;

				PropertyInfo keyProp = ObtainPKProperty();
				IDictionary props = new Hashtable();

				if (instance != null)
				{
					props[keyProp.Name] = keyProp.GetValue(instance, null);
				}
				
				if (UseModelName)
				{
					controller.Redirect(controller.AreaName, controller.Name, "edit" + Model.Type.Name, props);
				}
				else
				{
					controller.Redirect(controller.AreaName, controller.Name, "edit", props);
				}
			}
		}
开发者ID:nats,项目名称:castle-1.0.3-mono,代码行数:51,代码来源:UpdateAction.cs

示例2: Perform

		public bool Perform(ExecuteEnum exec, IRailsEngineContext context, Controller controller)
		{
			// Read previous authenticated principal from session 
			// (could be from cookie although with more work)
			
			User user = (User) context.Session["user"];
			
			// Sets the principal as the current user
			context.CurrentUser = user;
			
			// Checks if it is OK
			if (context.CurrentUser == null || !context.CurrentUser.Identity.IsAuthenticated)
			{
				// Not authenticated, redirect to login
				NameValueCollection parameters = new NameValueCollection();
				parameters.Add("ReturnUrl", context.Url);
				controller.Redirect("login", "index", parameters);
				
				// Prevent request from continue
				return false;
			}
			
			// Everything is ok
			return true;
		}
开发者ID:ralescano,项目名称:castle,代码行数:25,代码来源:AuthenticationFilter.cs

示例3: PerformActionProcess

		protected override void PerformActionProcess(Controller controller)
		{
			object instance = null; 
			
			try
			{
				AssertIsPost(controller);

				instance = binder.BindObject(Model.Type, Model.Type.Name, 
				                                    builder.BuildSourceNode(controller.Form));

				CommonOperationUtils.SaveInstance(instance, controller, errors, ref prop2Validation, true);

				SessionScope.Current.Flush();

				if (UseModelName)
				{
					controller.Redirect(controller.AreaName, controller.Name, "list" + Model.Type.Name);
				}
				else
				{
					controller.Redirect(controller.AreaName, controller.Name, "list");
				}
			}
			catch(Exception ex)
			{
				errors.Add("Could not save " + Model.Type.Name + ". " + ex.Message);
			}

			if (errors.Count != 0)
			{
				controller.Context.Flash[Model.Type.Name] = instance;
				controller.Context.Flash["errors"] = errors;
				
				if (UseModelName)
				{
					controller.Redirect(controller.AreaName, controller.Name, "new" + Model.Type.Name);
				}
				else
				{
					controller.Redirect(controller.AreaName, controller.Name, "new");
				}
			}
		}
开发者ID:nats,项目名称:castle-1.0.3-mono,代码行数:44,代码来源:CreateAction.cs

示例4: Perform

		public bool Perform(ExecuteEnum exec, IRailsEngineContext context, Controller controller)
		{
			_userAddFilter.Perform(exec,context,controller);
			if (Thread.CurrentPrincipal!=null && Thread.CurrentPrincipal.Identity.IsAuthenticated){
				log.Debug("authenticated");
				return true;
			}
			log.Debug("not authenticated");
			controller.Redirect("intro","index");
			return false;
		}
开发者ID:qwinner,项目名称:NetBPM,代码行数:11,代码来源:AuthenticationCheckFilter.cs

示例5: Execute

		public void Execute(Controller controller)
		{
			object instance = null;

			try
			{
				int id = Convert.ToInt32(controller.Form[prefix + ".id"]);

				instance = ActiveRecordMediator.FindByPrimaryKey(arType, id);

				ActiveRecordMediator.Delete(instance);

				controller.Redirect(controller.Name, "list");
			}
			catch(Exception ex)
			{
				controller.Flash["errormessage"] = ex.Message;
				controller.Flash[prefix] = instance;

				controller.Redirect(controller.Name, "confirmdelete", controller.Query);
			}
		}
开发者ID:ralescano,项目名称:castle,代码行数:22,代码来源:CrudActionProvider.cs

示例6: RedirectToNotice

		/// <summary>
		/// Redireciona para a página que avisa sobre a restrição do browser.
		/// </summary>
		/// <param name="controller">O <see cref="Controller"/> que não passou na validação</param>
		protected virtual void RedirectToNotice(Controller controller)
		{
			if (String.IsNullOrEmpty(RedirectArea))
				controller.Redirect(RedirectController, RedirectAction);
			else
				controller.Redirect(RedirectArea, RedirectController, RedirectAction);
		}
开发者ID:elementar,项目名称:Suprifattus.Util,代码行数:11,代码来源:MozillaOnlyFilter.cs


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