0

A bit new to Umbraco, so this might be a bit of a scattered question.

I'm using 5.1.

I have a document type called Auction with a selected Template called Auction Details

My end goal is to call this controller method on my AuctionSurfaceController

    [ChildActionOnly]
    public PartialViewResult Detail(string id)
    {
        Guid auctionId;
        if (Guid.TryParse(id, out auctionId))
        {
            var auction = auctionService.Client.GetAuction(auctionId);
            return PartialView(auction);
        }
        return null;
    }

As of this moment when I go to /Auction - it hits this method and passes in "Auction" into the method, when I go to /Auction/{GUID} i just get a 404

Could I please get some general guidance - or requests for clarifications on how to accomplish this. I would very much appreciate it

Cheers!

Hugo Forte
  • 5,718
  • 5
  • 35
  • 44

1 Answers1

0

It sounds like the routing is working properly.

Assuming that you're executing from the context of being on an 'auction detail' page, it would then make sense that /{GUID} would serve as the id parameter. (rather than www.mysite.com/auctions/auction/id)

Sometimes this question comes up because there's more than one form on a page, and it's difficult to figure out how umbraco will know which controller Umbraco will post to. This is where the bind attribute comes into play.

However, if you want to use custom routing, because Umbraco 5 is built on MVC, you can always create your own areas and controllers.

seraphym
  • 1,126
  • 1
  • 8
  • 21
  • Cheers, a few follow-ups: You say the routing seems to work correctly - but I'm getting a 404 on auction/{GUID} doesn't that mean that the routing isn't working correctly. I tried creating a custom route like this: routes.MapRoute( "auction", // Route name "auction/{id}/", // URL with parameters new { controller = "Auction", action = "AuctionDetails" } // Parameter defaults ); But when I use that, I does go into the controller, but seems to be outside of the umbraco context, i.e, the IUmbracoRenderModel was empty. – Hugo Forte Jun 08 '12 at 16:08
  • To the first point: If you action detail page is 'auctions', then it would make sense that the routing would be www.mysite.com/auctions/id, rather than www.mysite.com/auctions/auction/id. Because this could potentially cause a conflict (say if we had a login partial, and an auction detail on the same page), we use the bind attribute to route. To the second, assuming that you're creating a completely new controller, check out the tutorial here: http://our.umbraco.org/forum/core/umbraco-5-general-discussion/26029-Umbraco-5-How-to-create-a-custom-controller?p=0#comment108786 – seraphym Jun 08 '12 at 22:26