我正在构建一个流畅的界面,并希望在我的控制器外调用下面的代码...
return RedirectToAction("Activity");
Run Code Online (Sandbox Code Playgroud)
我该如何设计这种方法?我有:
public FluentCommand RedirectOnSuccess(string url)
{
if (IsSuccess)
;// make call here...
return this;
}
Run Code Online (Sandbox Code Playgroud)
注意:IsSuccess设置在这里:
public FluentCommand Execute()
{
try
{
_command.Execute();
IsSuccess = true;
}
catch (RulesException ex)
{
ex.CopyTo(_ms);
IsSuccess = false;
}
return this;
}
Run Code Online (Sandbox Code Playgroud)
我称之为流畅的界面:
var fluent = new FluentCommand(new UpdateCommand(param,controller,modelstate)
.Execute()
.RedirectOnSucess("Actionname");
Run Code Online (Sandbox Code Playgroud)
您可以将 的实例存储HttpContextBase为流畅界面中的字段,并且当您需要重定向时:
var rc = new RequestContext(context, new RouteData());
var urlHelper = new UrlHelper(rc);
context.Response.Redirect(urlHelper.Action(actionName), false);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3305 次 |
| 最近记录: |