Call return RedirectToAction ("Activity") of the external controller

I am creating a free interface and would like to call the code below my controller ...

return RedirectToAction("Activity"); 

How do I create this method? I have:

  public FluentCommand RedirectOnSuccess(string url) { if (IsSuccess) ;// make call here... return this; } 

Note. IsSuccess is installed here:

 public FluentCommand Execute() { try { _command.Execute(); IsSuccess = true; } catch (RulesException ex) { ex.CopyTo(_ms); IsSuccess = false; } return this; } 

I call my free interface:

 var fluent = new FluentCommand(new UpdateCommand(param,controller,modelstate) .Execute() .RedirectOnSucess("Actionname"); 
+6
source share
1 answer

You can save an instance of HttpContextBase as a field inside your free interface and when you need to redirect:

 var rc = new RequestContext(context, new RouteData()); var urlHelper = new UrlHelper(rc); context.Response.Redirect(urlHelper.Action(actionName), false); 
+4
source

Source: https://habr.com/ru/post/894803/


All Articles