0

I'm trying to link my view to the controller, and I used @Html.BeginForm and seemed to have given it the correct arguments, but whenever I test my application and submit the form I receive a

404 resource cannot be found error.

Here is the error text from the page:

Server Error in '/' Application. The resource cannot be found. Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

Requested URL: /reportController/addReport

Specifically, here is my code for my view (addReport.cshtml):

@using (@Html.BeginForm("addReport", "reportController", FormMethod.Post, new { @class = "form-class" }))
{

And here is my code for the reportController.cs:

[HttpPost]
public ActionResult addReport(String reportName, String reportCategory, String reportDescription, String reportDataSource) 
{

If I try and set the form up using a basic html type=form, and then complete the action=~/Controllers/... portion, visual studio does not show me any of the controllers attached to my project. So maybe there's an issue with my current view (addReport.cshtml) not seeing the controller (reportController.cs)

I've tried researching the error, but perhaps I'm not searching for the right details. I read this post and tried to follow along with it to get my results but it seems to not be working well.

I think that there is potential that the project was set up incorrectly when it was first created, so I also researched into changing the GUIDs in case that might be the issue.. but now I've got nothing and reached a brick wall.

Community
  • 1
  • 1
PackersFan
  • 43
  • 6
  • 3
    `"report"`, not `"reportController"` –  Mar 13 '17 at 03:47
  • @StephenMuecke Thanks! That's what the issue was. Is it because I should be referencing the model's name or the object I'm trying to deal with, not the controller's name? I'm trying to learn and figure out exactly what was wrong.. but again, thanks a ton! – PackersFan Mar 13 '17 at 04:39
  • The 2nd parameter of `BeginForm()` is the name of the controller but without the `"Controller"` suffix (it has nothing to do with the name of the model) –  Mar 13 '17 at 04:42

0 Answers0