ASP.NET MVC提供验证失败错误

时间:2014-01-22 19:02:40

标签: asp.net .net asp.net-mvc entity-framework unobtrusive-validation

我正在创建一个ASP.NET MVC4 Web应用程序。我的数据库位于Hostgator(因此它不是本地主机)。即使在我的电脑中(使用VS2012时),网站的运行速度也非常慢。很多时候我有一个验证失败的错误(你可以在那里看到它),在某些形式,大多数时候实际上工作。我怀疑这是一个与数据库连接的问题(我正在使用实体框架6),也许会话过快,或其他一些问题。也许这两个问题({1}运行速度很慢。{2}表格中的验证错误,有30%的时间。)是相关的吗?

修改 我也有验证注释。如果缺少某些输入,我会在客户端捕获它。问题是我在表格中输入相同的信息。有时候它有效,有时它不是......

###Server Error in '/' Application.###

Validation failed for one or more entities. See 'EntityValidationErrors' property for more details. The validation errors are: The FirstName field is required.; The LastName field is required.; The FirstName field is required.; The LastName field is required.; The FirstName field is required.; The LastName field is required.; The FirstName field is required.; The LastName field is required.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Data.Entity.Validation.DbEntityValidationException: Validation failed for one or more entities. See 'EntityValidationErrors' property for more details. The validation errors are: The FirstName field is required.; The LastName field is required.; The FirstName field is required.; The LastName field is required.; The FirstName field is required.; The LastName field is required.; The FirstName field is required.; The LastName field is required.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 


[DbEntityValidationException: Validation failed for one or more entities. See 'EntityValidationErrors' property for more details. The validation errors are: The FirstName field is required.; The LastName field is required.; The FirstName field is required.; The LastName field is required.; The FirstName field is required.; The LastName field is required.; The FirstName field is required.; The LastName field is required.]
   RentalsForceProject.DAL.UnitOfWork.Save() +490
   RentalsForceProject.Controllers.LeadController.Create(CreateLeadViewModel model) +205
   lambda_method(Closure , ControllerBase , Object[] ) +118
   System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +261
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +39
   System.Web.Mvc.Async.<>c__DisplayClass42.<BeginInvokeSynchronousActionMethod>b__41() +34
   System.Web.Mvc.Async.<>c__DisplayClass39.<BeginInvokeActionMethodWithFilters>b__33() +124
   System.Web.Mvc.Async.<>c__DisplayClass4f.<InvokeActionMethodFilterAsynchronously>b__49() +838059
   System.Web.Mvc.Async.<>c__DisplayClass37.<BeginInvokeActionMethodWithFilters>b__36(IAsyncResult asyncResult) +15
   System.Web.Mvc.Async.<>c__DisplayClass2a.<BeginInvokeAction>b__20() +33
   System.Web.Mvc.Async.<>c__DisplayClass25.<BeginInvokeAction>b__22(IAsyncResult asyncResult) +838644
   System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__18(IAsyncResult asyncResult) +28
   System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +15
   System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +65
   System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +15
   System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +51
   System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult asyncResult) +42
   System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +15
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +51
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +606
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288

0 个答案:

没有答案