How to use ModelBinder classes in Controllers when using Umbraco Cloud.
First question...
I have an Umbraco Cloud Project I have just started, and for the first time I want to use the ModelBinder.
When using Umbraco Cloud you have a website instead of a Web Application.
You also have a .Core Project where you have a controllers folder. How do I access the generated strongly typed classes in my controllers in my .Core project when the classes are generated in the Website project?
Second question...
Also, in the past before I started using the model binder, I would always make custom view models, do logic in my controller then pass that custom view model to my view.
When using the Model Binder, assuming I can get the strong types classes in my controller, should I still be making a custom view model class now I have a strong typed object can I just pass that straight in to the view... I'm a little confused about the correct approach, my gut is telling me I should still using a custom view model.
How to use ModelBinder classes in Controllers when using Umbraco Cloud.
First question... I have an Umbraco Cloud Project I have just started, and for the first time I want to use the ModelBinder.
When using Umbraco Cloud you have a website instead of a Web Application.
You also have a .Core Project where you have a controllers folder. How do I access the generated strongly typed classes in my controllers in my .Core project when the classes are generated in the Website project?
Second question... Also, in the past before I started using the model binder, I would always make custom view models, do logic in my controller then pass that custom view model to my view.
When using the Model Binder, assuming I can get the strong types classes in my controller, should I still be making a custom view model class now I have a strong typed object can I just pass that straight in to the view... I'm a little confused about the correct approach, my gut is telling me I should still using a custom view model.
Thanks in advanced.
OK, Looks like I have got it working but I'm not 100% sure if this is the way it should be done.
Step 1.
Sent Model Binder mode in the web config to DLL with the following settings
This will cause Umbraco to generate model classes based on your Document Types. - (by clicking generate models button) which are located in:
Umbraco.Web.PublishedContentModels.dll in the bin folder. of your .Web project
Step 2
From the .Core project Add a reference to Umbraco.Web.PublishedContentModels.dll the bin folder of the .Web project.
Now in your controller classes in your .core project you can now use your strongly typed Generated model like this:
Would love to know if this is how others are using model binder in cloud.
is working on a reply...