[RESOLVED]Strange error when redirecting route (MVC5)

My route config :

    routes.MapRoute(
    "LastTwoRoute",
    "thong-ke-ket-qua-xo-so-2-so-cuoi/{cityID}/{numbers}/{days}/{onlySpecial}",
    new { controller = "LastTwo", action = "Index", 
            cityID = "MB", 
            numbers = "",
            days = 1000,
            onlySpecial = false
    });

My controller :

        [HttpGet]
        public ActionResult Index(string cityID, string numbers, int days, bool onlySpecial)
        {
            
            LastTwoParameters lastTwoParameters = new LastTwoParameters();
            lastTwoParameters.listCities = Common.GetDropDownCitiesList();
            lastTwoParameters.listLastTwoResult = new List<getReport_LastTwo_Result>();
            
            if (TempData["Redirection"] != null || !string.IsNullOrEmpty(numbers) )
            {
                if (!string.IsNullOrEmpty(cityID) && days > 0)
                {
                    using (KQXS context = new KQXS())
                    {
                        lastTwoParameters.listLastTwoResult = context.getReport_LastTwo(cityID, numbers, days, onlySpecial).ToList();
                    }
                }

            }
            return View(lastTwoParameters);
        }

        [HttpPost]//Run action method on form submission
        public ActionResult Index(List<Cities> c, string cityID, string numbers, int days, bool onlySpecial)
        {
            TempData["Redirection"] = true;
            return RedirectToRoute("LastTwoRoute", new { cityID = cityID, numbers = numbers, days = days, onlySpecial = onlySpecial });
        }

Now I’m facing this problem :

- On my local host, after clicking the submit button when the page is first loaded without entering any parameters, it is fine, but on my host, it generated this error :

>  No route in the route table matches the supplied values.

You can visit the link for further detail : http://iketqua.net/thong-ke-ket-qua-xo-so-2-so-cuoi , please note that if you want to get the error above, don’t modify or enter any parameters, just click the `submit` button

I have recored a video-screen to demonstrate the difference between localhost and online host, please take a look : https://www.youtube.com/watch?v=4mmepl3n6x8&feature=youtu.be&hd=1

Nevermind, solved it! After updating .NET Framework to version 4.5, everything is fine!

Leave a Reply