创建对象后,尽管对象已正确创建,但我的页面不会继续到详细信息页面。ASP.Net MVC 3 - 成功创建后没有详细信息重定向
以下是我的代码:
Function Create(ByVal collection As FormCollection) As ActionResult
Dim _NieuweKlant As New Domain.Slave.Klant
Try
If ModelState.IsValid Then
TryUpdateModel(_NieuweKlant, collection)
_NieuweKlant.UpdatedON = Now
_NieuweKlant.LaatsteWijzigingGebruiker = Now
'_NieuweKlant.LaatsteActie = Now
KlantService.createKlant(_NieuweKlant)
KlantService.SaveKlant()
'check validstate
Return Details(_NieuweKlant.KlantID)
End If
Catch ex As System.Data.Entity.Validation.DbEntityValidationException
Dim Errors = ex.EntityValidationErrors.First
For Each propertyError In Errors.ValidationErrors
ModelState.AddModelError(propertyError.PropertyName, propertyError.ErrorMessage)
Next
Return View(_NieuweKlant)
Catch ex As System.Data.Entity.Infrastructure.DbUpdateException
Return View(_NieuweKlant)
Catch Ex As Exception
' Console.Out.Write("Bericht:" & vbCrLf & Ex.Message)
' Console.Out.Write("InnerException: " & vbCrLf & Ex.InnerException.ToString)
Return View()
End Try
End Function
我也已经尝试RedirectToAction和调试的时候似乎没有是一个错误。它只是不会重定向或转到其他操作。
您是否遇到异常?如果不是,则呈现什么视图? – krolik
尝试返回查看(“详细信息”,_ NieuweKlant.KlantId)而不是返回详细信息(_NieuweKlant.KlantId) –