Developer forum

Forum » Feature requests » Solutionset DW MVC

Solutionset DW MVC

Mikkel Toustrup Olsen
Reply

Hello,

Would it be possible to get a solution set for Dynamicweb with MVC implemented. By this I mean somewhat a raw structure, with maybe 1 view, 1 controller 1 model etc :) - nothing fancy, just a template/blueprint on how you think we, as developers, should approach this framework in Dynamicweb.

Thanks

/MikkelTO


Replies

 
Dmitrij Jazel
Reply

+1

 
Nicolai Høeg Pedersen
Reply
This post has been marked as an answer

Hi Mikkel and Dmitrij

I'll have a How-To made for the new documentation site.

But it is really really simple - it takes 2 mins. Just create an empty project with MVC and Webforms folders and install Dynamicweb into that solution and add controllers, views etc. to that. Just be aware of mxing Global.asax and web.config.

Attached a preliminary document and a sample solution to illustrate the steps and a final solution (That needs some Dynamicweb dlls though)

BR Nicolai

Votes for this answer: 1
 
Mikkel Toustrup Olsen
Reply

Perfect Nicolai, thanks a ton!

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Hi Nicolai,

Great document, thanks for writing that.

In addition to your debugging options, couldn't you also set up Visual Studio to point to your IIS site on the Web tab, restart in Admin mode and debug? That has always worked for me.

Imar

 
Nicolai Høeg Pedersen
Reply

Of course... Just never did it that way!

 
Mikkel Toustrup Olsen
Reply

Nicolai,

Do you guys have an approach on how to utilize MVC with e.g. eCom or modules in general. By "standard" we obviously are able to utilize dw tags within page/paragraph templates.

Would we be able to create controllers like:  ProductListController, CartController and access the module specific data from these?

Regards

Mikkel

 
Nicolai Høeg Pedersen
Reply

Hi Mikkel

Well, yes you can access everything using the Dynamicweb API from any controller. Not sure why you would do that in your controller though... But anyways. See dump.

If you create a ProductListController - you would create a model for use with the view that you return by that controller. If you do that, you have to do everything by hand - you kind of bypass the entire frontend of Dynamicweb and all the logic that handles i.e. a list of products. It makes no sense.

You would use ASP.NET MVC with Dynamicweb if you have something completely custom sitting on the 'side' or being used for administration of a custom module (we also use MVC for some stuff in DW).

The Dynamicweb frontend is a "controller" itself (PageView - not asp.net MVC controller, but our own concept of it) and has the models (Template instances) - it is generic and you access it through @GetValue (or even @Model). Agreed it is not ASP.NET MVC.

In DW9 we introduce the concept of @Model in templates, that would give you partially type strong models (not including items, custom fields etc that are defined after the model is compiled)

I'll be happy to spend an hour with you to talk about this.

BR Nicolai

Capture.PNG
 
Nicolai Høeg Pedersen
Reply

The guide is now online: http://doc.dynamicweb-cms.com/Default.aspx?ID=8036

 
Umar Farooq
Reply

Hi Nicolai,

When i try to setup a Visual studio project and edit the code behined file as it says in the documentation i dont get access to PageviewControl() and get and error "doesn't exist in Dynamicweb.Frontend". niether i can find any thing like PageviewControl in DW9 api Documentation. Is it been change? How to fix this Problem.

 

/umar

 
Nicolai Høeg Pedersen
Reply

Umar, this is a guide for a DW8, and it will not work with DW9 in the same way.

In DW9 we do not have PageViewControl and default.aspx, so simply delete that file (Default.aspx) - or skip that part in the guide.