I was looking over some code from a MVC3 nuget package, and I noticed that some methods in the controller used virtual, like public virtual ActionResult WhatEver() and the others where how I have always seen then, public ActionResult WhatEver2().
Why would someone do this? What are the benefits?
The only possible benefit is that you can override that method in an inheriting class.
It’s hard to say what the specific benefits of that are without knowing details about the library and this method’s place within it. Say it’s a CMS library and the ActionResult returns a dialog box. Marking that method virtual might allow you (the consumer of the library) to subclass the controller and modify the dialog’s behavior in some way.