I have a simple route...[controller]/{region} in my Index Controller.
So in the url you would see.. http://localhost:51588/Movies/malta (where 'malta' is the region)
And in the code for the subsequent index.cshtml view which list the movies of 'malta' view I have..
@model IEnumerable<MaltaMoviesMVCcore.Models.Movie>
@{
ViewData["Title"] = "Movies";
}
Q...I would like to add the 'region' dynamically to the above ["Title"] so it shows as 'Locations - Malta' I've tried.... ViewData["Title"] ="Movies - " @Model.Region; But get an error "IEnumerable does not contain a definition for 'Region'....."
This works fine in a typical 'Details view' where the model is simply....
@model MaltaMoviesMVCcore.Models.Movie and not ienumerable.
Create a MovieModelClass:
and init it inside of your conroller
Change your model inside of the view :
After this you can use
You can access your movies list using :