Route Issue

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
12 anos atrás
I have added a new object like category but it is called BodyPart. I have it workign in all ways except one. ANy help with how to debug woudl be approciated.

Routes:

           routes.MapLocalizedRoute("BodyPartList",
                            "body/all/",
                            new { controller = "Catalog", action = "BodyPartAll" },
                            new[] { "Nop.Web.Controllers" });
            routes.MapLocalizedRoute("BodyPart",
                            "b/{bodypartId}/{SeName}",
                            new { controller = "Catalog", action = "BodyPart", SeName = UrlParameter.Optional },
                            new { conditionId = @"\d+" },
                            new[] { "Nop.Web.Controllers" });

The first route worksI can get a page of all bodyParts. On that page I have the follwoing code:

@model IList<BodyPartModel>
@{
    Layout = "~/Views/Shared/_ColumnsThree.cshtml";

    //title
    Html.AddTitleParts(T("PageTitle.BodyParts").Text);
}
@using Nop.Core;
@using Nop.Core.Infrastructure;
@using Nop.Web.Framework.UI;
@using Nop.Web.Models.Catalog;
<div class="bodypartlist-page">
    <div class="page-title">
        <h1>@T("BodyParts.List")</h1>
    </div>
    <div class="clear">
    </div>
    <div class="bodypart-grid">
        @if (Model.Count > 0)
        {
            @(Html.DataList<BodyPartModel>(Model, 3,
                    @<div class="bodypart-item">
                        <h2 class="bod-title">
                            <a href="@Url.RouteUrl("BodyPart", new { bodypartId = item.Id, SeName = item.SeName })" title="@item.PictureModel.Title">
                                @item.Name</a>
                        </h2>
                        <div class="picture">
                            <a href="@Url.RouteUrl("BodyPart", new { bodypartId = item.Id, SeName = item.SeName })" title="@item.PictureModel.Title">
                                <img style="border-width: 0px;" alt="@item.PictureModel.AlternateText" src="@item.PictureModel.ImageUrl"
                                        title="@item.PictureModel.Title" /></a>
                        </div>
                    </div>
                ))
        }
    </div>
</div>





For some reason it is producing a URL of http://SiteURL/Body/ instead of http://siteurl/b/1/sename

Have I missed another spot to update the route?

The controllers are:

public ActionResult BodyPart(int bodypartId, CatalogPagingFilteringModel command)
public ActionResult BodyPartAll()
[ChildActionOnly]
        //[OutputCache(Duration = 120, VaryByCustom = "WorkingLanguage")]
        public ActionResult BodyPartNavigation(int currentBodyPartId)


Anyways any ideas or pointers is welcome.
12 anos atrás
Looks like you're calling an ivalid parameter...

routes.MapLocalizedRoute("BodyPart",
                            "b/{bodypartId}/{SeName}",
                            new { controller = "Catalog", action = "BodyPart", SeName = UrlParameter.Optional },
                            new { conditionId = @"\d+" },
                            new[] { "Nop.Web.Controllers" });


conditionId should be bodypartId
12 anos atrás
GEEEEEZ!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! I looked over that a hundred times. damnit!!!!!!!!!!!!!!!!!!!!!!!


Thanks for catching it.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.