MvcSiteMapProvider
MvcSiteMapProvider copied to clipboard
Breadcrumb URL is generated without route parameters for HttpPost action
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)
...
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.