Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

@Model not supported in Razor Views for VB?

Is not the @Model MyModelClass notation not supported in VB Razor Views? It's not working for me. What is the construct for it?

like image 701
Brian Mains Avatar asked Feb 27 '11 20:02

Brian Mains


People also ask

What does @model represent in Razor view?

The @model directive provides a cleaner and more concise way to reference strongly-typed models from view files. This works (and is still supported with ASP.NET MVC 3) – but is a little verbose. The above syntax is conceptually the same as before (except with a lot fewer characters).

Which of the following are valid extensions for Razor view?

The Razor syntax consists of Razor markup, C#, and HTML. Files containing Razor generally have a . cshtml file extension.

What does the @model declaration at the top of view do?

The declaration at the top will do two things for you: It will allow intellisence to know what type you are using when you type in @Model or use any of the Html helper extensions. It will also check at runtime that model passed in can be cast to the type the view expects.

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

The equivalent construct to @model statement in C# Razor in VB is @ModelType.

like image 163
jevakallio Avatar answered Oct 14 '22 19:10

jevakallio