Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP MVC ChildActionOnly should have routing

I don't know if this is normal but should ChildActionOnly methods ask for route? For example

[ChildActionOnly]
        public PartialViewResult List(string countryCode, string cityName)
        {...
            return PartialView(model);
        }

I render it like:

@{Html.RenderAction("List", "MyController", new { area = "MyArea", countryCode = ViewBag.CountryCode, cityName = ViewBag.CityName });}

In debug I get on upper line:

No route in the route table matches the supplied values.

UPDATE

context.MapRoute("name",
                "",
                new { area = "MyArea", controller = "MyControlelr", action = "List", countryCode = UrlParameter.Optional, cityName = UrlParameter.Optional });
like image 352
1110 Avatar asked Feb 07 '12 22:02

1110


1 Answers

Yes it does.

All [ChildActionOnly] does is say that this action cannot be accessed via the URL (e.g a regular HTTP GET), rather it must be executed by Html.Action or Html.RenderAction. It's not a new HTTP request, but it still goes through the MVC request pipeline (controller/action selection via route values).

like image 200
RPM1984 Avatar answered Sep 28 '22 03:09

RPM1984