controller-actions

Should I make my ASP.NET MVC controller actions virtual?

江枫思渺然 提交于 2019-12-01 04:06:10
File -> New Project for ASP.NET MVC projects used to generate controllers with virtual actions. I'm not sure if that stopped with MVC 2 or MVC 3, but is this no longer a best practice? archil T4MVC Does make action methods virtual. If you are using it, it should make action methods virtual, no other way it can work The current documentation for ASP.NET MVC 3 does not show virtual methods. I'm not really sure what making them virtual would gain you, as I've never subclassed controllers to override actions. If you make them virtual then it will make the controllers easier to mock if you are

Should I make my ASP.NET MVC controller actions virtual?

主宰稳场 提交于 2019-12-01 01:44:36
问题 File -> New Project for ASP.NET MVC projects used to generate controllers with virtual actions. I'm not sure if that stopped with MVC 2 or MVC 3, but is this no longer a best practice? 回答1: T4MVC Does make action methods virtual. If you are using it, it should make action methods virtual, no other way it can work 回答2: The current documentation for ASP.NET MVC 3 does not show virtual methods. I'm not really sure what making them virtual would gain you, as I've never subclassed controllers to