0

I Understand what my error is. from other answers like Asp.Net Core 3.1 405 Method Not Allowed and I can see that one of the solutions is javascript or not. I also understand the reason I am gettign 405 is cause my [HTTPGET] request is blocked. What I am trying to do here is really simple. I want to send the imdbID to my controller here is my code...

Controller : From what I gather I access the controller and the reason this happens is cause imdbID is null. I get nothing in my console.write

[Route("api/Movies")]
        [HttpPost]
        public IActionResult FindMovie(string imdbID)
         {
            Console.WriteLine(imdbID);  
            var item = _db.Movies.Where(s => s.imdbID.Equals(imdbID)).FirstOrDefault();
              if (item != null)
            {
                return NotFound();
            }
           return View();
        }

and here is the view ... from where I try to send imdbID I am trying to do it via imdbID

<tbody>
            @foreach (var item in Model.Search)
            {
                @item.Runtime
                //       each table row is assigned with the imdbID returned from the API. if the user clicks one of the rows
                //then the system will 1st check the database if this movie exist in the database. if not then it will be added and then desplayed
                //if the movie exist then it will be automatically desplayed to the user without making another API call.
                <tr >
                    <td><img src="@item.Poster" class="img-thumbnail" alt="Responsive image" width="200"> </td>
                    <td>@item.Title</td>
                    <td>@item.Year</td>
                    <td>  <a asp-controller="Home" asp-action="FindMovie" asp-for="@item.imdbID">Back to List</a> </td>
                </tr>
            }
        </tbody>
Demeteor
  • 1,193
  • 2
  • 17
  • 33

0 Answers0