dotvvm icon indicating copy to clipboard operation
dotvvm copied to clipboard

Hosting Razor partial views in DotVVM pages

Open exyi opened this issue 7 years ago • 5 comments

I could be cool to have an integration between Razor and DotVVM, so you could host a DotVVM user control in a Razor view or vice versa, or be able to share master/layout pages. Although for a big project having two identical master pages does not matter too much, it could make it much easier to try DotVVM for few pages in an existing project.

Using Razor partial views and layout pages should not be very complicated, as they are simply text templates. Using dotvvm controls inside razor views will be more challenging, as controls require client-side data context, can have dotvvm resource dependencies and so on.

cc @zulq

exyi avatar Jul 21 '17 10:07 exyi

The usage of Razor partial view in DotVVM could look like this:

<razor:PartialView Path="~/Views/Razor/something.cshtml" DataContext="{value: something}" />

We should also think about an option to pass ViewBag, route information and other things the partial view may need. If you find any other things that can be passed to the partial view, please post a commend here to discuss it.

tomasherceg avatar Jul 24 '17 10:07 tomasherceg

The opposite direction (hosting DotVVM user controls in Razor views) will be very tricky and may not be possible. If we decide to do it, we'll create a separate issue for that.

tomasherceg avatar Jul 24 '17 10:07 tomasherceg

I think we shouldn't mess up dotvvm razor integration with bad practice from MVC like @viewbag. Everything what the component needs, it should get from her model.

martindybal avatar Jul 24 '17 10:07 martindybal

@tomasherceg I agree that hosting dotvvm control inside razor view is probably more complicated than I originally thought, but it could be at least useful to have a html helper that would host a dotvvm page inside an iframe. That should be simple and could cover most use cases.

exyi avatar Jul 24 '17 10:07 exyi

I see this feature more as part of DotVVM Contrib than in the framework, but it can be quite useful.

tomasherceg avatar Jul 20 '21 10:07 tomasherceg