简体   繁体   English

ASP.NET web 页面代码在后面

[英]ASP.NET web pages code behind

So does the new ASP.NET web pages (also called razor pages) framework using the Razor view engine (referring to this: http://www.asp.net/webmatrix/tutorials/1-getting-started-with-webmatrix-and-asp-net-web-pages ) not actually have any code-behind file? So does the new ASP.NET web pages (also called razor pages) framework using the Razor view engine (referring to this: http://www.asp.net/webmatrix/tutorials/1-getting-started-with-webmatrix-and- asp-net-web-pages )实际上没有任何代码隐藏文件? I looked on the samples and couldn't find an example.我查看了样本,但找不到示例。 I assume no, but maybe there is a header reference where you can link it that I might be missing?我认为没有,但也许有一个 header 参考,您可以在其中链接它,我可能会丢失?

Can anyone confirm?任何人都可以确认吗?

Thanks.谢谢。

According to this blog you can easily have code-behind.根据this blog,您可以轻松地进行代码隐藏。 http://www.compiledthoughts.com/2011/01/aspnet-mvc3-creating-razor-view-engine.html http://www.compiledthoughts.com/2011/01/aspnet-mvc3-creating-razor-view-engine.html

Do you need it or not this is for you to decide.您是否需要它由您决定。 I strongly resent answers which starts with "you dont need it..".我强烈反对以“你不需要它..”开头的答案。

Every person in the world must have a choice whether to shoot for a moon or shoot himself in the foot.世界上每个人都必须做出选择,是向月球射击还是向自己的脚射击。 Thats what I think is right.那是我认为是对的。

There are no code behind files for Razor Views because you don't need them. Razor 视图没有代码隐藏文件,因为您不需要它们。 You are writing the presentation logic using the Razor syntax on the view itself.您正在视图本身上使用 Razor 语法编写表示逻辑。

Razor views simplifies the mixing of raw HTML with dynamic content rendered using Razor syntax so you don't need a separate file. Razor 视图简化了原始 HTML 与使用 Razor 语法呈现的动态内容的混合,因此您不需要单独的文件。 Furthermore there are no such things as Controls or Components in razor views so you don't need to configure them in a separate file.此外,razor 视图中没有ControlsComponents之类的东西,因此您无需在单独的文件中配置它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM