問題の答えが見つかりませんでしたので、この質問をもう一度お願いします。 MVC5とEntity FrameworkでVisual Studioを使用してフォームを送信しています。私の問題は、フォームにアクセスしようとすると、「リソースを見つけることができません」というエラーが表示されます(フランス語で画面に表示されます。 は、ここに私のアーキテクチャです:ここでリソースMVCエンティティフレームワークを見つけることができません
MonLivredor /コントローラ/ HomeController.cs
MonLivredor /ビュー/ホーム/ Formulaire.cshtml
は、私は、フォームからの投稿データを取得するために、コントローラでの使用方法であり、 :
[HttpPost]
public ActionResult Formulaire()
{
String nom = Request.Form["nom"];
String mail = Request.Form["mail"];
String message = Request.Form["message"];
Commentaire com = new Commentaire(nom, mail, message);
context.Liste.Add(com);
context.SaveChanges();
return View(context);
}
そして最後に、私はVS 2015で手動で起動しよう私のフォーム:
<h2>Formulaire</h2>
<form method="post" action="/Home/Formulaire">
<h2>Nom</h2>
<input type="text" id="nom" name="nom"/>
<h2>Mail</h2>
<input type="text" id="mail" name="mail"/>
<h2>Message</h2>
<input type="text" id="message" name="message"/>
</form>
だけで助けることができる場合には、ここで私のglobal.asax.csは、任意の変更なしである:私は、冗長対象のため申し訳ありません
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Web;
namespace MonLivredor.Models
{
public class Commentaire
{
[Key]
public int ID { get; set; }
public String Nom { get; set; }
public String Mail { get; set; }
public String Message { get; set; }
public DateTime CreateDate { get; set; }
public Commentaire(String nom, String mail, String message)
{
CreateDate = DateTime.Now;
this.Nom = nom;
this.Mail = mail;
this.Message = message;
}
public Commentaire()
{
}
}
}
:
namespace MonLivredor
{
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
GlobalConfiguration.Configure(WebApiConfig.Register);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
}
}
はここでモデルCommentaire.csです動作するものは見つかりませんでした。ルーティングを変更しようとしましたが、どちらの方法も役に立たないようです。そのようなフォームであなたの助け:)あなたがタグ名を使用する必要があります
_Formulaire.cshtm l_ビュー? – Steve
それはCommentaire.csと呼ばれています。私はそれを追加します –