我如何使用与迪朗达尔CSHTML文件? [英] How can I use cshtml files with Durandal?

查看:180
本文介绍了我如何使用与迪朗达尔CSHTML文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在VS2012的DurandalJS入门套件模板...所有的伟大工程...

I got the DurandalJS StarterKit template on VS2012... All works great...

但在一些观点,我需要做这样的事情:

But in some views I need to do something like that:

@if (Roles.IsUserInRole("Administrators"))
{
   <p>Test</p>
}

然而,随着迪朗达尔所有我的意见是'html的文件......这有可能使用'.cshtml文件访问这样的一些信息?

However with durandal all my views are '.html' files... Is that possible to use '.cshtml' files to access some information like that?

或者是有任何其他方式做到这一点与迪朗达尔?

Or is there any other way to do that with durandal?

少年

推荐答案

是的,你完全可以用CSHTML文件,迪朗达尔,并采取在服务器上利用剃刀。我想这也意味着你要MVC,这样你就可以做到这一点,并使用它的路由。

Yes, you can absolutely use cshtml files with Durandal and take advantage of Razor on the server. I assume that also means you want MVC, so you can do that too and use its routing.

如果你不要;不想路由,那么你可以设置webpages.Enabled在web.config中,为其他意见建议

If you don;t want the routing then you can set the webpages.Enabled in the web.config, as the other comments suggest.

<add key="webpages:Enabled" value="true" /> 

这篇关于我如何使用与迪朗达尔CSHTML文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆