Reputation: 5355
I am going to create a web application using .NET.
I have choosen to use Knockout
for front end and for service I will use WebApi
.
I have seen two approaches:
1) using only html
files; in this case no Razor syntax is ever used
vs
2) using 'cshtml' files; in this case Knockout html markup will be used in most cases, but sometimes some Razor things are also possible. I am not sure if this is useful, but I imagine that sometimes could be.
In this case first call would be through MVC controller, that will load cshtml file and appropriate Knockout model (that will consume webapi services). Am I right?
Which approach would be better?
P.S. From Knockout perspective I would like to use it as described in this example: http://learn.knockoutjs.com/WebmailExampleStandalone.html#Spam/52
Upvotes: 1
Views: 29
Reputation: 17943
From my experience, I feel you should have .cshtml
as shell/container only, all the views should be in HTML
, this will be better in terms of performance as the HTML
gets cached in clients browser.
When you have .cshtml
as a shell, you will have more control over the application and it will be easy for you to implement bundling, minification, security, logging etc at server side.
This approach really works well if you have a single page application (SPA
), where you are using any routing engine to load your views/partials (html).
Upvotes: 1