asp.net mvc 4 - Does Razor View @model initialize the model? -


I have a razor view that uses the @model keyword I added breakpoint to the constructor of the model and whenever the scene is broken by breakpoint , It does not mean that it does not go into the constructor.

No @ model declares only model type If you have a model Example is required, you have to make one in your controller and pass it to see, i.e.:

  return view (new MyModel ()); However, it is not always necessary to create an example, it is only necessary if you want to use the instance property, such as the list of items that you need to be repeated.   

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -