0
votes

I am using MVC5 routing attribute in my project.

I have search controls on Home Page. When user click on Search button, control values will be passed to Search Controller action.

Before using MVC5 routing attribute URL was http://localhost:5344/Search/View1?City=XYZ&Cat=ABC

Home Controller Code:

public ActionResult IndexFront(string City, string Search, string hidCategory, string btnSubmit)
    {


        return RedirectToAction("View1", "Search", new { CityS = City, SearchS = Search, Cat = hidCategory });          


    }

Search Controller code:

 [Route("Search/{CatS}/{CityS}/{SearchS?}", Name="SearchWithCityCat")]
    public ActionResult View1(string CityS, string SearchS, string CatS)
    {

        var searchModel = new SearchModel();

        return View(searchModel);

    }

After decorating View1 with routing attribute and click on Search button it shows the same URL and gives error "Page not found".

I am not finding any way out to solve this problem.

Am I doing correct?

Please help. thanks in advance.

1
Try return RedirectToAction("SearchWithCityCat", "Search",artm

1 Answers

0
votes

Thanks all.

Found out the answer. I was passing wrong parameter name from Home controller.