The focus is on the “controllerName As String” – part – of the Html.BeginForm function.
The 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>
The Controller:
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
The Question:
EDIT: The call to the View is done above the request call to the HTTP POST method with the function “Therequest” – in the Controller.
The reference to the ControllerName has been done in the second part of the Html.BeginForm, whereas in the first part of Html.BeginForm the reference to the function to call a request to the HTTP POST method is done.
The problem I am having is, that after pressing the submit button, the call to the function (in the controller) is not done in the set location. Where the following error message comes up, after the ´submit button´ is pressed:
Server Error in Application.
The view ‘Therequest’ or its master was not found or no view engine supports the searched locations. The following locations were searched: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.InvalidOperationException: The view
‘Therequest’ or its master was not found or no view engine supports
the searched locations. The following locations were searched:~/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
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.
The “search”, or also the “call” is not done in the set location. Where by the parameter array of the Html.BeginForm, the to be executed function name is set, and also, the controllerName is set – which is set to (root/Controllers/HomeController.vb) – and in the third part the method is set to POST.
The question is, what is causing it to not do the call in the set location?
The Tools Used: VB.NET 2012, MVC 4, Visual Studio 2012, Microsoft SQL Server 2012
it is trying to render View named
Therequest.vbhtmlwhereas you have your view namedTherequestform.vbhtmlEither change the view name to
Therequest.vbhtmlor change the controller name toTherequestformand all the places where it is referenced