MVC 3 不使用 Razor?
使用 EditorFor 语法创建 MVC3 站点是否真的需要 Razor 引擎?我见过的几乎所有示例都使用 Razor。我们正在开发我们的第一个 MVC 项目,并且不想处于前沿......
Is the Razor engine really needed to create an MVC3 site with EditorFor syntax? Almost all the examples I've seen are using Razor. Were working on our first MVC project, and would rather not be on the bleeding edge ...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
简短的回答是“不”,您不必使用 Razor。恕我直言,您确实应该重新考虑放弃 ASPX 视图引擎。 Razor 是一个非常稳定的 HTML 生成平台。
The short answer is "no", you don't have to use Razor. IMHO you should really reconsider moving away from the ASPX view engine. Razor is a very stable platform for generating HTML.
您也可以使用网络表单视图引擎。如果您想将视图从 razor 转换为 Webform,您可以在 此处找到 vs 扩展< /a>. Telerik 还有一个转换工具,您可以在 Telerik 网站此处找到它
You can use webform viewengine also. if you want to convert view from razor to webform you can find vs extension here. Also telerik has a tool to convert it you can find it here on telerik site
我同意这里每个人的观点。
-10,000 表示想要使用 aspx 语法:)
去买剃须刀……你需要 2 分钟才能学会。请参阅语法参考:
http://haacked.com /archive/2011/01/06/razor-syntax-quick-reference.aspx
只需记住 @Something 期望输出并将 HtmlEncode 为您(这是一个巨大的+++)但是@{一些其他代码}不会将输出呈现到流中。所以
@Html.TextBoxFor() 效果很好但是
@{Html.TextBoxFor())} 我相信不会发出任何东西,你会想知道为什么没有输出。
除了那些陷阱之外......它太棒了,你将永远不想再回到aspx。说真的..你很快就会拿起它。
I agree with everyone here.
-10,000 for wanting to use aspx syntax : )
Go for razor.. it will take you 2 minutes to learn. See the syntax reference at:
http://haacked.com/archive/2011/01/06/razor-syntax-quick-reference.aspx
Just remember that @Something expects output and will HtmlEncode it for you (which is a huge +++) but that @{ some other code} does not render output to the stream. So
@Html.TextBoxFor() works great but
@{Html.TextBoxFor())} I believe won't emit anything and you'll be wondering why there is no output.
Other than those gotchas.. its awesome and you will never ever want to go back to aspx again. Seriously.. you will pick it up in no time.