mosh-hamedani / vidly-mvc-5

952 stars 1.52k forks source link

Problem in going to the Customer/Detail page and consuming it #383

Open MukulSah opened 1 year ago

MukulSah commented 1 year ago

i have added the routing [Route ("Customers/Details/{id}")] public ActionResult Details(int id) { var customer = _context.Customers.SingleOrDefault(c =>c.Id == id);

        if (customer == null)
            return HttpNotFound();
        else
        return View(customer);
    }

still it didnt work also i applied Route.MapRoute( name: "Details", url: "{Customers}/{Details}/{id}", defaults: new { controller = "Customers", action = "Details", id = UrlParameter.Optional } );

this also didnt worked it is giving the error of Server Error in '/' Application. The resource cannot be found. and url is something like this http://localhost:50904/Customers/Details?Length=9

when im redirecting it http://localhost:50904/Customers/Details/1 it is giving me the error of Server Error in '/' Application. The model item passed into the dictionary is of type 'Aura.Models.Customer', but this dictionary requires a model item of type 'Aura.ViewModels.RandomMovieViewModel'.

1HazArd1 commented 11 months ago

The URL has been incorrectly defined. The controller and the action name shouldn't be in the curly bracket "Customers/Details/{id}". The entities that are variable-like parameters are inside curly brackets while the controller and action here are fixed in this case

MukulSah commented 1 month ago

The URL has been incorrectly defined. The controller and the action name shouldn't be in the curly bracket "Customers/Details/{id}". The entities that are variable-like parameters are inside curly brackets while the controller and action here are fixed in this case

Thnxx bro