In a Composite C1 application, I am trying to pass values from the URL to the MVC Player function, but I have trouble because the values are part of the path and not in the query string.
The URL looks like this:
/AuctionDetailsGallery/3624734/Test-Versteigerung-2
AuctionDetailsGallery is a Composite C1 Page which includes the MvcPlayer function. 3624734 is the (dynamic) ID, "Test-Versteigerung-2" is a userfriendly name
The MvcPlayer is then supposed to call
/AuctionViewer/FilterGalleryPositions
("AuctionViewer" is the controller and "FilterGalleryPositions" the action.)
The ID has to be passed to the action, but under a different name ("SelectedAuctions").
So essentially, if the user calls
/AuctionDetailsGallery/3624734/Test-Versteigerung-2
I want to render the MVC action
/AuctionViewer/FilterGalleryPositions?SelectedAuctions=3624734
How can I do this?
I set the MvcPlayer path to "/AuctionViewer/FilterGalleryPositions"
and played around with the routes, but I always get the message
The controller for path '/3624734/Test-Versteigerung-2' was not found or does not implement IController.
That's because the Render function checks for PathInfo and replaces the Path I set with the PathInfo if available. I guess it would be more useful if the PathInfo was appended, but I am unsure how to route my values with the current MVC Player implementation.
If I understand your question correctly I believe you are asking about routes.
With Attribute routing simply declare the route over the controller action (assuming controller name is AuctionViewerController):
[Route("AuctionDetailsGallery/{selectedAuctions}/Test-Versteigerung-2")]
public ActionResult FilterGalleryPositions(int selectedAuctions)
{
...
}
With a routetable you might define something like this:
routes.MapRoute(
name: "AuctionDetails",
url: "AuctionDetailsGallery/{selectedAuctions}/Test-Versteigerung-2",
defaults: new { controller = "AuctionViewer", action = "FilterGalleryPositions" }
);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.