I have tried to add multiple models in one view at asp.net MVC, but this show me error like this:
Line 1: @using myapp.Models;
Line 2: @model appViewModel
Line 3: @model ForgotPasswordViewModel
Line 4:
Can you please help me?
I have tried to add multiple models in one view at asp.net MVC, but this show me error like this:
Line 1: @using myapp.Models;
Line 2: @model appViewModel
Line 3: @model ForgotPasswordViewModel
Line 4:
Can you please help me?
You cannot directly add multiple Model to one view Instead you can do something like this (Combining all models in to a single Model)
Line 1: @using myapp.Models;
Line 2: @model MyMultpileViewModel
/**Your Model **/
class MyMultpileViewModel
{
public AppViewModel appViewModel{get;set;} // First Model
public ForgotPasswordViewModel forgotPasswordViewModel{get;set;} // Second Model
}
Create a View Model(Class) containing both classes as members and return that as model from controller.