シンプルなお問い合わせフォームを作成しようとしています。これが私のモデルです:
Imports System.Data.Entity
Imports System.ComponentModel.DataAnnotations
Public Class Contact
Public Property Name() As String
Public Property Title() As String
Public Property Company() As String
Public Property CompanyAddress() As String
Public Property PhoneNumber() As String
Public Property NumberOfEmployees() As String
Public Property EmailAddress() As String
Public Property Subject() As String
Public Property Message() As String
End Class
これが私の見解です:
@ModelType MyBlog.Contact
@Code
ViewData("Title") = ViewBag.Title
End Code
@Using Html.BeginForm()
@Html.LabelFor(Function(model) model.EmailAddress)
@Html.EditorFor(Function(model) model.EmailAddress)
@Html.ValidationMessageFor(Function(model) model.EmailAddress)
@<input type="submit" value="Send" />
End Using
そして、ここに私のコントローラーがあります:
Function Contact() As ActionResult
Return View("", "_FinalSubPageLayout", "")
End Function
私が得るエラーは次のとおりです。
ディクショナリに渡されたモデル アイテムは「System.String」タイプですが、このディクショナリには「MyBlog.Contact」タイプのモデル アイテムが必要です。
このエラーを解決するにはどうすればよいですか? ありがとうございました。