User1065418170 posted
I just played with WebPages (Razor2) website project template and figured out how its really works. I noticed that there is a "hidden" background generated C# class (eg.: _Page_Default_cshtml) which created by the engine. This class inherited from WebPage
and contains an Execute overriden method which produces the output. This concept basicly looks good but when I look at the code inside the generated Execute function I became little dissapointed! Its actually generetes a lot of WriteLiteral statements filled
by strings copied from original cshtml file. Is this trully the best approach to process every request?
As I see now this WebPages technique translates all off the html codes into PRINT statements and generates new html code as response. I think this not so effective. Developer writes a html code -> engine creates a class -> class creates a html output
line-by-line. OMG!
I'm a developer so this approach means to me its better to write my own Execute function to generate html output without cshtml files but directly from my controllers (database, flatfile etc). As I digged deeper I also noticed that I cannot override generated
class so I no chance to change processing steps in general way.
My question is, is it possible to create my custom class inhertied from WebPage and then skip background generated class which automatically inherited from my own WebPage class in default way? Its clear to me that I can creat my own class and set @inherits
keyword to that in cshtml files but finally the automatically generated class always override my own Execute processing.