Is "@model dynamic" valid on an ASP.NET MVC3.cshtml page?

I am writing a small ASP.NET MVC3 application that I run on Mac OS X. It works fine, but I have an unresolved issue. I am using Razor syntax. For example, this is a simplified version of the login page:

@model Livestream.LoginModel
<!DOCTYPE html>
<html>
<head>
    <title>Remote Observation</title>
    <link type="text/css" rel="stylesheet" media="all" href="/Content/CSS/main.css" /> 
</head>
<body>
    @{
        dynamic dave = "Sign In";
    }
    <div class='normal center'>
        <p><img src='/Content/images/logo.png' /></p>
        @using(Html.BeginForm("Login", "Main")) {
            <div class='loginBox'>
                 <p>Username<br />@Html.TextBoxFor(m => m.Username)</p>
                 <p>Password<br />@Html.PasswordFor(m => m.Password)</p>
                 <p><input type='submit' value='@dave'></p>
            </div>
        }
    </div>
    <script>
        document.getElementById('Username').focus();
    </script>
</body>
</html>

Good, so no problem with that. It works great on both Mac OS X and Linux.

After reading the comments in this post by Scott Gu , I thought I realized that I could replace @model Livestream.LoginModelwith @model dynamic. However, when I tried this, it will not work on either OS X or Linux.

Given that I am developing in ASP.NET, this may seem crazy, but I do not have access to the Windows machine with .NET to try this. I am using Mono .

@model dynamic ? - , , ? Mono?

.NET.NET- (CLR 4.0), . .

, , , cshtml. , , .

EDIT. " dave" , , .NET 4. dynamic, @model. ?

+3
1

@model dynamic . , Razor @model dynamic, , . , , , , MVC . ?

.cshtml , :

@model dynamic

@Model.Name

UPDATE

, :

@Html.TextBoxFor(m => m.Username)

, . :

@Html.TextBox("Username")
+9

All Articles