I have 2 controllers CustomerController and PrivatemessageController
Customers has a nonaction method
private readonly ICustomerService _customerService;
public Customer(....) << autofac Ioc
{
}
[NonAction]
protected CustomerNavigationModel GetCustomerNavigationModel(Customer customer)
{
var model = new CustomerNavigationModel();
.... _customerSerice...
return model;
}
I’d like to get GetCustomerNavigationModel value from CustomerController as I don’t want to recreate the same method for PrivateMessageController, is that possible in ASP.NET MVC 3.0 ?
Two options come to mind here.
Make the method public static:
Create a base controller and implement the method there. Have both your controllers derive from your base controller: