Hi @SPIDEY JOE ,
From your description, I think you want to implement redirection to a specific controller in your model class.
This should be impossible.
The logic to determine if a redirect is required and what the redirect should be belongs to the controller. The model just gets the data the view needs. This happens after you decide which view to render. Think of redirects as instructions to perform different controller actions.
https://learn.microsoft.com/en-us/dotnet/api/system.web.mvc.controller.redirecttoaction?view=aspnet-mvc-5.2#system-web-mvc-controller-redirecttoaction(system-string-system-string)
So, something like this:
public ActionResult Foo()
{
var result = someOtherClass.Bar();
if (result.WhatEver)
{
return RedirectToAction("yourAnotherActionName","yourAnotherControllerName");
}
return View(...);
}
Best regards,
Lan Huang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.