maartenba / MvcSiteMapProvider

An ASP.NET MVC SiteMapProvider implementation for the ASP.NET MVC framework.
Microsoft Public License
537 stars 220 forks source link

Breadcrumb URL is generated without route parameters for HttpPost action #419

Open andrew-potachits opened 8 years ago

andrew-potachits commented 8 years ago

Sitemap.xml (fragment):

  <mvcSiteMapNode title="Home" controller="Home" action="Index">
    <mvcSiteMapNode title="Projects" controller="Projects" action="Index">
      <mvcSiteMapNode title=" " controller="Projects" action="View" preservedRouteParameters="ProjectId">
        <mvcSiteMapNode title="Quote composition" controller="QuoteConfiguration" action="AddMoreSections" preservedRouteParameters="ProjectId,ProjectName"/>
        <mvcSiteMapNode title="Quote Generation" controller="QuoteGeneration" action="GenerateQuote" preservedRouteParameters="ProjectId,ProjectName" />
...

when I navigate to /QuoteConfiguration/AddMoreSections?ProjectId=1&QuoteId=2 (via HttpGet), the breadcrumb works fine: Project URL has ID:

/Projects/View?ProjectId=1

however when I navigate to: QuoteGeneration/GenerateQuote (HttpPost, ProjectId is in the post data), the ID in Project URL is missing: /Projects/View

my action methods look similar for post and get:

        [HttpPost, ValidateAntiForgeryToken]
        [SiteMapTitle("ProjectName", Target = AttributeTarget.ParentNode)]
        public ActionResult GenerateQuote(GenerateQuoteViewModel model)
...
        [SiteMapTitle("ProjectName", Target = AttributeTarget.ParentNode)]
        public async Task<ActionResult> AddMoreSections(int projectId, int quoteId, string returnUrl)
...
NightOwl888 commented 8 years ago

In its current incarnation, preserved route parameters first tries to get the value from route values, then from the query string. The form collection is not part of the equation.

But then, this does seem like a good idea so I will consider this a feature request.