本文整理汇总了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);
}
}
}
示例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;
}
示例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");
}
}
}
示例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;
}
示例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);
}
}
示例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);
}