工作每當我嘗試後我的狀態,我得到以下錯誤:表單提交不提交時
An error occurred while getting provider information from the database. This can be caused by Entity Framework using an incorrect connection string. Check the inner exceptions for details and ensure that the connection string is correct.
public class ContactController : Controller
{
[HttpGet]
public ActionResult Index()
{
return View(new ContactMessage());
}
[HttpPost]
public ActionResult Index(ContactMessage post)
{
if(ModelState.IsValid)
{
//Save to Database
using (var db=new ContactMVC.Data.ContactDatabase())
{
post.DateSent = DateTime.Now;
db.ContactMessages.Add(post);
db.SaveChanges();
}
//redirect
TempData["ContactMessage"] = post;
return RedirectToAction("SucessfulMessage");
}
return View(post);
}
public ActionResult SucessfulMessage()
{
var message = (ContactMessage)TempData["ContactMessage"];
return View(message);
}
}
可以向我們展示內部異常嗎? – alisabzevari
您是否檢查連接字符串和內部異常,如錯誤所示? – Zabavsky
@alisabzevari什麼內部異常? –