Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is WebViewPage in MVC3 abstract?

What is the point of

public class ThemedViewPage<T> : WebViewPage<T>
{
    public override void Execute()
    {

    }
}

What am I supposed to do with it? I ask because I've left it empty and the world is a good place and everything appears to work - just updating a demo I'm running this afternoon and this is a question I'll likely be asked.

like image 226
Rob Ashton Avatar asked Nov 12 '10 10:11

Rob Ashton


People also ask

What is mvc4?

ASP.NET MVC 4 is a framework for building scalable, standards-based web applications using well-established design patterns and the power of the ASP.NET and the . NET framework. This new, fourth version of the framework focuses on making mobile web application development easier.

What is ASP Net mvc3?

ASP.NET MVC 3 is a framework for developing highly testable and maintainable Web applications by leveraging the Model-View-Controller (MVC) pattern.

How can you specify comments by using Razor syntax?

Razor uses the syntax "@* .. *@" for the comment block but in a C# code block we can also use "/* */" or "//". HTML comments are the same, "<!

What is the file extension for using Razor view with Visual Basic syntax?

Razor allows you to write a mix of HTML and server-side code using C# or Visual Basic. Razor view with visual basic syntax has . vbhtml file extension and C# syntax has . cshtml file extension.


1 Answers

Razor works by generating a class that inherits from a base class. The default class it inherits from is WebViewPage<T>. When you express @inherits ThemedViewPage<Something> you're telling the code generator to create a class that then inherits from ThemedViewPage<Something>.

You don't actually implement the Execute method, as the Razor parser which generate this method. It's worth reading Andrew Nurse's Blog, Ben @ BuildStarted's Blog and perhaps even my own as we've been working recently on building a standalone Razor Templating Engine, so needed to learn how it all worked internally.

like image 139
Matthew Abbott Avatar answered Oct 02 '22 21:10

Matthew Abbott