【发布时间】:2012-10-28 02:07:32
【问题描述】:
重点是 "controllerName As String" - Html.BeginForm 函数的一部分。
HTML:
root/Views/Home/Therequestform.vbhtml
<h2>Therequestform</h2>
@Html.BeginForm("Therequest", "Home", method:= FormMethod.Post)
<fieldset>
<input type="text" name="ColorName" />
<input type="submit" name="ColorName_SubmitButton" />
</fieldset>
控制器:
root/Controllers/HomeController.vb
Function Therequestform() As ActionResult
Return View()
End Function
<HttpPost()>
Function Therequest() As ActionResult
Response.Write("The color you have submitted: " & Request.Form("ColorName"))
Return View()
End Function
End Class
问题:
编辑:对视图的调用是在对 HTTP POST 方法的请求调用之上完成的,该方法在控制器中具有“请求”功能。
对ControllerName 的引用已在Html.BeginForm 的第二部分完成,而在Html.BeginForm 的第一部分对调用request 到HTTP POST method 的函数的引用已完成.
我遇到的问题是,在按下submit button 之后,对函数的调用(在控制器中)没有在设置的位置完成。在按下“提交按钮”后出现以下错误消息:
应用程序中的服务器错误。 未找到视图“请求”或其主视图,或者没有视图引擎支持搜索的位置。搜索了以下位置:
说明:在执行过程中发生未处理的异常 当前的网络请求。请查看堆栈跟踪以获取更多信息 有关错误的信息以及它在代码中的来源。
异常详情: System.InvalidOperationException:视图 未找到“请求”或其主人或没有视图引擎支持 搜索到的位置。搜索了以下位置:
~/Views/Home/Therequest.aspx
~/Views/Home/Therequest.ascx
~/Views/Shared/Therequest.aspx
~/Views/Shared/Therequest.ascx
~/Views/Home/Therequest.cshtml
~/Views/Home/Therequest.vbhtml
~/Views/Shared/Therequest.cshtml
~/Views/Shared/Therequest.vbhtml
源错误:在执行过程中产生了一个未处理的异常 当前的网络请求。有关原产地和位置的信息 可以使用下面的异常堆栈跟踪来识别异常。
“搜索”或“呼叫”未在 set 位置完成。其中通过Html.BeginForm的参数数组,设置了executed函数名,同时设置了controllerName——设置为(root/Controllers /HomeController.vb) - 在第三部分中方法设置为POST。
问题是,是什么导致它没有在设置的位置进行调用?
使用的工具: VB.NET 2012、MVC 4、Visual Studio 2012、Microsoft SQL Server 2012
【问题讨论】:
标签: .net vb.net visual-studio asp.net-mvc-4