【问题标题】:Syntax error ',' expected in Razor ASP.NET MVC6 [closed]Razor ASP.NET MVC6 中预期的语法错误“,”[关闭]
【发布时间】:2017-10-14 19:29:38
【问题描述】:

我正在尝试在我的练习项目中使用 tagHelper,但是当我运行应用程序时,我在图像中收到错误 ,我是 MVC 新手。

ContactViewModel:

public class ContactViewModel
{
    [Required]
    public string Name { get; set; }
    [Required]
    [EmailAddress]
    public string Email { get; set; }
    [Required]
    [StringLength(4096, MinimumLength = 10)]
    public string Message { get; set; }
}

联系方式.cshtml:

 @model WebApplication1.ViewModels.ContactViewModel;
@{ 
    ViewBag.Title = "Contact";
}

@section scripts {
<script src="~/lib/jquery-validation/dist/jquery.validate.min.js"></script>
<script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js"></script>
}
<h1>Contact Me</h1>

<form>
    <label asp-for="Name"></label>
    <input  asp-for="Name"/>
    <label asp-for="Email"></label>
    <input  asp-for="Email"/>
    <label asp-for="Message"></label>
    <textarea cols="40" rows="4" asp-for="Message"></textarea>
    <div>
        <input type="submit" value="Send Message"/>
    </div>
</form>

我做错了什么?

【问题讨论】:

    标签: c# razor asp.net-core asp.net-core-tag-helpers


    【解决方案1】:

    替换

    @model WebApplication1.ViewModels.ContactViewModel;

    @model WebApplication1.ViewModels.ContactViewModel

    【讨论】:

    • 非常感谢你@serhiyb....你让我开心...
    猜你喜欢
    • 1970-01-01
    • 2012-08-02
    • 1970-01-01
    • 2021-09-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-16
    • 1970-01-01
    相关资源
    最近更新 更多