0

I have problem using redirect to another action. here is what I send from my View:

    @using(Html.BeginForm("redirect","Home",FormMethod.Get,new { id="Indexform",name="Myform" }))
{<input type="hidden" name="id" value="1" />}

And here is controller:

 public ActionResult redirect(string id = ""){

      return RedirectToAction("MainSearch","Home",new
                       {
                           My_Categories = id,
                           Area = "New England"
                       });
}

and the target action is MainSearch in Home Controller:

public ActionResult MainSearch(string My_Categories = "", string Area="Wales"){

    ViewBag.Area=Area;
    ViewBag.Category=My_Categories;
return View();
        }

My Routing Configuration is as following:

 public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Priosa",action = "Huvudmeny",id = UrlParameter.Optional }
            );
        }

Why do I get this error:

No route in the route table matches the supplied values.

2
  • Show you route definitions, and the MainSearch() method
    – user3559349
    Dec 17, 2017 at 0:52
  • I edited all files as above
    – Esmael
    Dec 18, 2017 at 0:34

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.