Asp.NET MVC3 Controller Class Extension

I am a pretty experienced .NET programmer as well as an MVC programmer with PHP. Now I'm new to MVC3 and trying to create my first work on this, so I am dealing with a few questions. For starters, how to extend the controller class? Can someone provide me with a guide / list of methods that I should implement?

Thanks!

+1
source share
2 answers

You do not need to implement any methods to extend the controller, although it would obviously be pretty stupid not to do this. You simply inherit it and override the methods you want to change.

If you do not know what methods need to be changed, I must ask the question, why do you want to expand it?

EDIT:

You can benefit from two large applications with MVC samples, Nerddiner and the Music Store. They give you a very good idea on how to create e-commerce sites, etc. In MVC. Do not accept them as the gospel, because they are models and should be simple. They currently do not use advanced techniques such as Injection Dependency or repository design. Some links to useful guides:

Lots of good videos here. Pluralsight is pretty straightforward

Music Store Tutorial

NerdDinner Tutorial

+4
source

You do not need to implement anything, just draw your class on System.Web.Mvc.Controller. As a rule, there is no real benefit to this, but in some cases it may be useful to make some general general class of the base controller that all controllers in your project could use.

Remember that when adding common methods to your controllers. It is often useful to add these methods to some lower level of your application or as helper methods on your models or view models.

+1
source

Source: https://habr.com/ru/post/1382576/


All Articles