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? I开发者_StackOverflow 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?
Can anyone confirm?
Thanks.
According to this blog you can easily have code-behind. 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. You are writing the presentation logic using the Razor syntax on the view itself.
Razor views simplifies the mixing of raw HTML with dynamic content rendered using Razor syntax so you don't need a separate file. 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.
精彩评论