0

I am a noob with Durandal and web MVC, so bear with me... :-)

I have researched this thread: How can I use cshtml files with Durandal?

I have check at this answer:https://stackoverflow.com/a/15539354/2261129

But it requires a dynamic controller with an action per view, I am working in a project with 100+ views so this is not going to work.

I am very intrigued about this answer from Maarten: https://stackoverflow.com/a/15636715/2261129

But I am in doubt in how to use this from Durandal?

Can anybody help me get started please??

help is greatly appreciated...

tak/gracias/thanks!

O

Community
  • 1
  • 1
omms
  • 1

1 Answers1

0

I actually preferred the first answer from Young, even though he preferred Maarten's. Using Young's answer, you could use .NET MVC routing to set up your views. Let's say I have a home view, about view, and other view. I could set up the routing like so:

    routes.MapRoute(
    name: "DurandalHome",
    url: "dynamic/home",
    defaults: new { controller = "RealHomeController", action = "Index" }
);
routes.MapRoute(
name: "DurandalAbout",
url: "dynamic/about",
defaults: new { controller = "RealHomeController", action = "About" }
);
routes.MapRoute(
name: "DurandalOther",
url: "dynamic/other",
defaults: new { controller = "OtherController", action = "Index" }
);

Obviously this would be a pain because you would have to do this for your 100 views, but that would prevent the need to change the physical locations of your views. I imagine the same could be done using the viewLocator or viewEngine on the durandal side, but I'm not certain about that.

DougJones
  • 774
  • 1
  • 9
  • 26
  • Just a note. You can use regular expressions to match routes. Not sure if this will fit the scenario but its nice to know. – Evan Larsen Apr 09 '13 at 17:36