What is the role of a controller in MVC?
Simple meaning
It receives the request, talks to services, and chooses a result like a view or redirect.
Open the full page for Why, Steps, Example and Key takeaway.
Panel-ready ASP.NET MVC questions for freshers and experienced developers. Practice at Coding Cadre in Faridabad, or Online from Delhi NCR.
It receives the request, talks to services, and chooses a result like a view or redirect.
Open the full page for Why, Steps, Example and Key takeaway.
A shape built for a screen, not the full domain entity.
Open the full page for Why, Steps, Example and Key takeaway.
ViewBag lasts for one request to the view.
Open the full page for Why, Steps, Example and Key takeaway.
Tag helpers build URLs from routing metadata so links stay correct when routes change.
Open the full page for Why, Steps, Example and Key takeaway.
It runs before each view and usually sets the Layout.
Open the full page for Why, Steps, Example and Key takeaway.
A ViewModel is a shape built for a screen, not necessarily a database entity.
Open the full page for Why, Steps, Example and Key takeaway.
It renders without the shared chrome for partials, emails, or print layouts.
Open the full page for Why, Steps, Example and Key takeaway.
It blocks CSRF on cookie-authenticated POSTs by requiring a token.
Open the full page for Why, Steps, Example and Key takeaway.
The action still runs but ModelState becomes invalid.
Open the full page for Why, Steps, Example and Key takeaway.
It locks down every action by default.
Open the full page for Why, Steps, Example and Key takeaway.
When the resource id does not exist or the user should not learn it exists.
Open the full page for Why, Steps, Example and Key takeaway.
It signs users in and out and handles lockouts and two-factor flows.
Open the full page for Why, Steps, Example and Key takeaway.
It returns 400 with a payload, often ModelState errors.
Open the full page for Why, Steps, Example and Key takeaway.
It fingerprints static files so browsers fetch new copies after publish.
Open the full page for Why, Steps, Example and Key takeaway.
Both emit form tags with action URLs
Open the full page for Why, Steps, Example and Key takeaway.
{*path} captures remaining segments.
Open the full page for Why, Steps, Example and Key takeaway.
Both pass data to views
Open the full page for Why, Steps, Example and Key takeaway.
It returns a 302 to another action using route values.
Open the full page for Why, Steps, Example and Key takeaway.
It stores data for the next request, often after redirect.
Open the full page for Why, Steps, Example and Key takeaway.
It limits a route parameter, like int or regex.
Open the full page for Why, Steps, Example and Key takeaway.