It's not mentioned in the Documentation for the video, but I beleive the narrator mentions that you must include the method name when accessing the ApiControllers via auto-routing. I beleive this rul to be true for auto contreoller routing as well.
Fair enought, someone may be able to add further. Just for kicks I tested one of my (fairly simple) Surface Controllers with an Index action, and can confirm that without the {action} (in the /umbraco/(surface|api)/{Controller}/{action} scheme) my Index ActionResult does not fire, but includeing '/index' it works fine...
I have only experianced umbraco 7 so can only talk from my experiance. btw when I said "I beleive this rul to be true for auto contreoller routing as well." apart from the awful typing, spelling and grammar I meant "I believe this to be true for SurfaceController auto routing"!
SurfaceController problem with index method
I have upgraded a umbraco websitet from 6.1.6 to 7.1.8 and after alot of issues it is now working as expected.
Except for this problem.
If i go to
http://localhost:55503/umbraco/Surface/Customer
i get a 404 error but when i go to
http://localhost:55503/umbraco/Surface/Customer/Index
I get the page i would expect.
I guess it is a routing problem but i dont know that may cause the problem.
I hope you can help me.
Can you post the code for the rooting file.
global.asax
protected override void OnApplicationStarted(object sender, EventArgs e)
{
Application_Start();
base.OnApplicationStarting(sender, e);
}
protected void Application_Start()
{
BundleConfig.RegisterBundles(BundleTable.Bundles);
RouteConfig.RegisterRoutes(RouteTable.Routes);
// Register the default hubs route: ~/signalr
RouteTable.Routes.MapHubs();
Bootstrapper.Initialise();
ConfigureAutomapping();
ModelBinders.Binders.Add(typeof(double), new DoubleModelBinder());
ModelBinders.Binders.Add(typeof(decimal), new DecimalModelBinder());
}
I have this in my routeconfig:
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(name: "Default", url: "{controller}/{action}/{id}",
defaults: new { action = "Index", id = UrlParameter.Optional });
Just an idea but have you tried with out the surface
http://localhost:55503/umbraco/Customer/Index
Yup i have and it didnt work.
I have made som changes and removed all surface controllers and just started using them as normal mvc controllers instead.
That works and now i dont have to add index to the url.
I beleive I read somewhere on umbraco.tv that the method is required regardless of there just being an index method...
Not sure but it might have been in this video : http://www.umbraco.tv/videos/umbraco-v7/developer/fundamentals/api-controllers/understanding-routing/
It's not mentioned in the Documentation for the video, but I beleive the narrator mentions that you must include the method name when accessing the ApiControllers via auto-routing. I beleive this rul to be true for auto contreoller routing as well.
Kind Regards,
Danny "Blatant"
It is not a api controller but a surface controller and before i upgraded from 6.1.6 to 7.1.8 i didnt have to add index to the url.
Fair enought, someone may be able to add further. Just for kicks I tested one of my (fairly simple) Surface Controllers with an Index action, and can confirm that without the {action} (in the /umbraco/(surface|api)/{Controller}/{action} scheme) my Index ActionResult does not fire, but includeing '/index' it works fine...
I have only experianced umbraco 7 so can only talk from my experiance. btw when I said "I beleive this rul to be true for auto contreoller routing as well." apart from the awful typing, spelling and grammar I meant "I believe this to be true for SurfaceController auto routing"!
Kind Regards,
Danny "Blatant"
is working on a reply...