ASP.NET MVC4 The controller for path '/enquiry/' was not found or does not implement IController. error returned for dropdownlist -
my application returning when navigate enquiry area, have working areas, brochure , enquiry , third follow (pay), when navigate brochure area error not displayed.
i have tried adding areas parameter in view error being thrown, both leaving string blank , enquiry shown below :
@html.action("dropdownlist", "enquiry base", new { type = "titles", areas = ""}) @html.action("dropdownlist", "enquiry base", new { type = "titles", areas = "enquiry"})
neither of these have resolved error.
currently in order display dropdownlist have viewmodel, partial view , unity bootstrapper in root:
itemsviewmodel
public class dropdownlistitem { public string text { get; set; } public string value { get; set; } } public class itemsviewmodel { private readonly list<dropdownlistitem> _items; public string selecteditem { get; set; } public ienumerable<selectlistitem> items { { var allitems = _items.select(i => new selectlistitem { value = i.value, text = i.text }); return defaultitem.concat(allitems); } } public ienumerable<selectlistitem> defaultitem { { return enumerable.repeat(new selectlistitem { value = "", text = mui.please_select }, count: 1); } } public itemsviewmodel() { } public itemsviewmodel(list<dropdownlistitem> items, string selected) { _items = items; selecteditem = selected; }
dropdownpartial
@using mbs.exec.mvc.viewmodels @model itemsviewmodel @html.dropdownlistfor(m => m.selecteditem, model.items)
bootstrapper
public static class bootstrapper { public static void initialise() { var container = buildunitycontainer(); dependencyresolver.setresolver(new unitydependencyresolver(container)); globalconfiguration.configuration.dependencyresolver = new unity.webapi.unitydependencyresolver(container); } private static iunitycontainer buildunitycontainer() { var container = new unitycontainer(); container.registertype<ibrochuremodel, militarybrochureviewmodel>(); container.registertype<ibrochuremodel, generalbrochureviewmodel>(); container.registertype<ibrochuremodel, standardbrochureviewmodel>(); container.registertype<ibrochuremodel, studentbrochureviewmodel>(); container.registertype<ienquirymodel, militaryenquiryviewmodel>(); container.registertype<ienquirymodel, generalenquiryviewmodel>(); container.registertype<ienquirymodel, standardenquiryviewmodel>(); container.registertype<ienquirymodel, studentenquiryviewmodel>(); container.registertype<iformdata, formdata>(); container.registertype<irestexecutiveservice, restexecutiveservice>(); return container; }
in order use dropdown in area created dropdownlist actionresult in enquirybasecontroller:
[childactiononly] public actionresult dropdownlist(string type, string selected) { if (type == "titles") { var items = new itemsviewmodel( (from g in _service.gettitles() select new dropdownlistitem { text = g.value, value = g.value }).tolist(), selected); return partialview("dropdownpartial", items); } else if (type == "leadsources") { var items = new itemsviewmodel( (from g in _service.getleadsources() select new dropdownlistitem { text = g.value, value = g.value }).tolist(), selected); return partialview("dropdownpartial", items); } return null; }
i use @html.action code above render dropdown on view.
does have ideas why error being thrown?
when call
@html.action("dropdownlist", "enquiry base", new { type = "titles", areas = ""})
you have space in controller name string.
try this:
@html.action("dropdownlist", "enquirybase", new { type = "titles", areas = ""})
i presume reason error goes '/enquiry/' because reading first part of string.
Comments
Post a Comment