Is there a mandatory relationship between a Controller Action and a View? I mean is it necessary to have a physical View (.aspx page) for each Action inside a Controller class?

Was it helpful?


There is no mandatory relationship between the Controller Action and a view. The controller is responsible for returning an ActionResult. The most usual way of doing this is by using a View, but they aren't hard wired. A view could be shared across Controllers for instance.

Also a Controller, can deal with the request purely on its own, returning a redirect, or a JSON result, or even its own html (though not recommended).


You can also return things like ContentResult in an action:

public ContentResult Index()
    return Content("Foobar!");

If this was called directly, this would be similar to:

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top