asp.net mvc - Adding @Html.Action to _layout errors with "No route in the route table matches the supplied values." -


my end goal have <script> line in _layout generated database data. step 1 me display comment line in "head" portion of page. have test program fine. when copy code on site "no route in route table matches supplied values." when run web. error pointing @html.action("ovars","myo") statement in _layout.

i have tried use glimpse , routedebugger not able data on route being generated , why failing. output routedebugger has list of 30 40 routes of "default" route in global.asax.cs. can assume these routes being created elsewhere in code.

@html.action("ovars","myo") 

the controller contains:

using system; using system.collections.generic; using system.linq; using system.web; using system.web.mvc;  namespace mysite.controllers {     public class myocontroller : controller     {         // childactiononly not allow direct displaying of page         [childactiononly]         public actionresult ovars()         {             return partialview("_ovars");         }     } } 

the _ovars partialview:

   <!-- test comment displaying --> 

global.asax.cs

public static void registerroutes(routecollection routes) {     viewengines.engines.clear();     viewengines.engines.add(new razorviewengine());      routes.ignoreroute("{resource}.ico");     routes.ignoreroute("{resource}.axd/{*pathinfo}");      routes.maproute(         "default", // route name         "{controller}/{action}/{id}", // url parameters         new { controller = "home", action = "index", id = urlparameter.optional } // parameter defaults                     ); } 

any suggestions on @ help. know there parameter set not aware of needs changed.

thanks

solved (but not understand "areas, more learn").

i changed line @html.action("ovars","myo") @html.action("ovars","myo", new { area = string.empty }).

i kept making code changes until received error message when looked found text similar "this error happen if inside view in area, use html.action helper. helper use area prepend, unless tell not to.". example presented add , new { area = string.empty } @html.action statement.

now @html.action working correctly , can move forward having controller access database information.

next on learning agenda "understanding areas".


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -