是否可以在单声道下使用 Razor 2.0 视图引擎? [英] Is it possible to use Razor 2.0 view engine under mono?

查看:26
本文介绍了是否可以在单声道下使用 Razor 2.0 视图引擎?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 Razor 2.0 的 条件属性功能,所以我尝试将 Razor 2.0 移植到我的 MVC3 应用程序.我关注了 this link 并成功运行了我的简单应用程序(使用一个 HomeController,一个 Index 动作和一个 *~/Views/Home/Index.cshtml 视图)在 Windows with ASP.NET 上.

I was insterested in Razor 2.0's condition attributes feature, so I tried to port Razor 2.0 to my MVC3 apps. I followed this link and successfully run my simple app (with one HomeController, one Index action and one *~/Views/Home/Index.cshtml view) on Windows with ASP.NET.

但是当我在 Ubuntu 上的 mono runtime 上部署我的应用时,它无法运行并继续报错 Cannot find view:

But when I deployed my app on mono runtime on Ubuntu, it fails to run and continues to report an error of Cannot find view:

/"应用程序中的服务器错误未找到视图索引"或其主视图,或者没有视图引擎支持搜索的位置.搜索了以下位置:~/Views/Home/Index.aspx ~/Views/Home/Index.ascx ~/Views/Shared/Index.aspx ~/Views/Shared/Index.ascx ~/Views/Home/Index.cshtml ~/Views/Home/Index.vbhtml ~/Views/Shared/Index.cshtml ~/Views/Shared/Index.vbhtml

Server Error in '/' Application The view 'Index' or its master was not found or no view engine supports the searched locations. The following locations were searched: ~/Views/Home/Index.aspx ~/Views/Home/Index.ascx ~/Views/Shared/Index.aspx ~/Views/Shared/Index.ascx ~/Views/Home/Index.cshtml ~/Views/Home/Index.vbhtml ~/Views/Shared/Index.cshtml ~/Views/Shared/Index.vbhtml

这个错误我google了一下,大部分文章都说是视图编译的问题,所以我以为是mono不能正确使用新Razor引擎的编译器编译Index.cshtml.

I googled for this error, most of the articles says it is a problem of view compiling, so I thought it is caused by mono cannot properly use the new Razor engine's compiler to compile Index.cshtml.

然后我将我的应用程序切换回 Razor 1.0 并且在单声道下一切正常,那么单声道无法运行 Razor 2.0 真的是个问题吗?或者有什么快速解决这个问题的方法吗?

I then switched my app back to Razor 1.0 and everythings works fine under mono, so is it really a problem that mono cannot run Razor 2.0? or is there any quick solution to this problem?

谢谢

推荐答案

理论上,Razor pages 可以与 Mono 一起使用 2.10.x 系列,但您必须将 Microsoft 的程序集与它捆绑到您的 Linux 机器中.

Razor pages worked with Mono, in theory, with version 2.10.x series, but you had to bundle Microsoft's assemblies with it into your Linux box.

自从 Mono 2.11.1,这些程序集现在默认捆绑在 Mono 中,因为 Microsoft 最近开源了 Razor(在 2012 年 3 月).

Since Mono 2.11.1, these assemblies are now bundled by default in Mono, because Microsoft open sourced Razor recently (on March 2012).

因此,如果我是你,我会尝试 Mono 2.11.3 以查看问题是否已在上游解决.如果没有,请在 http://bugzilla.xamarin.com/ 中提交一个错误并使用独立的测试用例进行重现它,并从这里链接到错误.

Hence, if I were you I would try Mono 2.11.3 to see if the problem is already fixed upstream. If not, please file a bug in http://bugzilla.xamarin.com/ with a standalone testcase to reproduce it, and link to the bug from here.

这篇关于是否可以在单声道下使用 Razor 2.0 视图引擎?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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