mvc HTTP 404 error

Asked

Viewed 51 times

1

Good,

I created an ASP:NET WEB Core 2.0 Appl project.
I created views and controllers.
When I do a Ubmit via:

<form asp-controller="Audit" asp-action="Search" method="post"> 

Instead of opening via (controller Audit, Iaction, search, Return View()) the/view Audit page in

http://localhost:62857/Home/Audit

tries to open (with error)

http://localhost:62857/Audit/Search.

The same is repeated for other views.

What I’m doing wrong?

NOTA1: I don’t have enough experience (yet) to use Routes and maps.
NOTA2: If I use eturn Content("AOC") I view AOC.

'Audit.cshtml' form Asp-controller="Audit" Asp-action="Search" method="post"> div class="Row">input type="search" id="inputSearch" name="inputSearch">input type="Submit" value="Search...">/div>/form>/form

Auditcontroller Public Iactionresult Search(string inputSearch) { Viewbag.Search = inputSearch;

        // return View("Index");
        // return View();
        // return Content("test audit");
        return View("~/Views/Home/Audit");
    }

Thank you for your attention

  • 1

    I don’t quite understand your doubt, are you having trouble finding the narrow way ? or the form is doing Submit for the Wrong Controller/Action ? You could post the code of your controller

  • From what I understand, that’s correct, because if you use ASP-CONTROLLER="Audit" it means you get the Audit controller. If you want to search for the Home controller, switch to ASP-CONTROLLER="Home"

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.