Redirect() public method

Redirects to the specified URL. All other Redirects call this one.
public Redirect ( string url ) : void
url string Target URL
return void
示例#1
0
		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);
				}
			}
		}
示例#2
0
		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;
		}
示例#3
0
		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");
				}
			}
		}
		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;
		}
示例#5
0
        public bool Perform(ExecuteEnum exec, IRailsEngineContext context, Castle.MonoRail.Framework.Controller controller)
        {
            U_UserInfo u = context.Session["logonUser"] as U_UserInfo;

            if (u == null)
            {
                Hashtable p = new Hashtable();
                p.Add("backUrl", context.Request.Uri.AbsoluteUri);
                controller.Redirect("/login", p);
                return(false);
            }
            return(true);
        }
示例#6
0
		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);
			}
		}
示例#7
0
		public void Execute(Controller controller)
		{
			object instance = null;

			try
			{
				ARSmartDispatcherController arController =
					(ARSmartDispatcherController) controller;

				ARDataBinder binder = (ARDataBinder) arController.Binder;
				binder.AutoLoad = AutoLoadBehavior.Always;

				TreeBuilder builder = new TreeBuilder();

				instance = binder.BindObject(
					arType, prefix,
					builder.BuildSourceNode(controller.Form));

				ActiveRecordMediator.Update(instance);

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

				controller.Redirect(controller.Name, "edit", controller.Query);
			}
		}
		/// <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);
		}