I'm trying to redirect a user from a method on a controller to another view but can't get it to work no matter what I do. What am I doing wrong? Here's my code:
public ActionResult SubmitReport(string JsonStringSend)
{
dynamic JSend = JObject.Parse(JsonStringSend);
var schema = JsonSchema4.FromType<ReportItem>();
var schemaData = schema.ToJson();
var errors = schema.Validate(JSend.JsonString);
schema = JsonSchema4.FromJson(schemaData);
//Check for errors and show them if they exist
if (errors.Count > 0)
{
//JSchema schema = JSchema.Parse(schema);
foreach (var error in errors)
Console.WriteLine(error.Path + ": " + error.Kind);
//JObject JsonString = JObject.Parse(JsonObj.JsonString.ToString());
//JObject JsonStringSent = JObject.Parse(JsonStringSend);
}
else
{
return Redirect("/Admin/Reporting/ReportManagement");
}
return View();
}
It never redirects. I've even tried these:
Response.Redirect(Url.Action("/ReportManagement"));
RedirectToRoute(new { contoller = "ReportManagement", action = "Reporting" });
return RedirectToRoute(new { contoller = "Reporting", action = "ReportManagement" });
return RedirectToAction("ReportManagement");
Nothing seems to redirect, what gives?
You don't redirect to a view, you redirect to an action or a route. If I'm correctly parsing the path you're attempting, where you have this:
return Redirect("/Admin/Reporting/ReportManagement")
should be
return RedirectToAction("Reporting", "ReportManagement", new { area="Admin" })
This assumes a Reporting action on a ReportManagementController class in the Admin area.