Razor ASP.NET MVC6 中预期出现语法错误“,”
Syntax error ',' expected in Razor ASP.NET MVC6
我正在尝试在我的练习项目中使用 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; }
}
Contact.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>
我做错了什么?
替换
@model WebApplication1.ViewModels.ContactViewModel;
和
@model WebApplication1.ViewModels.ContactViewModel
我正在尝试在我的练习项目中使用 tagHelper,但是当我 运行 应用程序时,我在图像中收到错误
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; }
}
Contact.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>
我做错了什么?
替换
@model WebApplication1.ViewModels.ContactViewModel;
和
@model WebApplication1.ViewModels.ContactViewModel