Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • NicolaiJee 30 posts 91 karma points
    Oct 19, 2014 @ 20:55
    NicolaiJee
    0

    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.

     

  • Ayo Adesina 445 posts 1058 karma points
    Oct 20, 2014 @ 11:09
    Ayo Adesina
    0

    Can you post the code for the rooting file.

    global.asax

  • NicolaiJee 30 posts 91 karma points
    Oct 20, 2014 @ 11:11
    NicolaiJee
    0

       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 });

  • Ayo Adesina 445 posts 1058 karma points
    Oct 20, 2014 @ 11:17
    Ayo Adesina
    0

    Just an idea but have you tried with out the surface

    http://localhost:55503/umbraco/Customer/Index

  • NicolaiJee 30 posts 91 karma points
    Oct 20, 2014 @ 11:20
    NicolaiJee
    0

    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.

  • Danny Blatant 91 posts 358 karma points
    Oct 20, 2014 @ 19:18
    Danny Blatant
    0

    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"

  • NicolaiJee 30 posts 91 karma points
    Oct 21, 2014 @ 10:55
    NicolaiJee
    0

    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.

  • Danny Blatant 91 posts 358 karma points
    Oct 21, 2014 @ 11:29
    Danny Blatant
    0

    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"

Please Sign in or register to post replies

Write your reply to:

Draft