HTTP Error 404.0 0 Not Found in MVC

The Resource you are looking for has been removed, had its name changed, or is temporarily unavailable.

I saw this error today while working on a MVC Web Project, this is a common error we get while running websites and performing any CRUD (Create, Read, Update, Delete) operation. The Stackoverflow forum is full of such queries so I decided to describe the fix here. You might not find it useful for your case but I think the majority of requests can be satisfied.
 
Let me show you an error page image here:

http-error-404.jpg

Look at the URL in the above image. The URL is requesting a view/page to edit the record but unfortunately the page is not found. Actually the page/view is already there but the problem is, we are not supplying the correct ID or say index to edit.

In other words we need an URL something like http://localhost:25349/demo/Edit/1 to edit the first record and http://localhost:25349/demo/Edit/2 to edit the second record. Yet in the preceding image we are not supplying the ID.
 
Let's fix it. Open the "Index" view of the "demo" controller and look at the existing code:
output-http-error-404.jpg

Oh! there is a comment instead of the ID parameter, so once you change it, such as in the following: 

  1. <td>  
  2.     @Html.ActionLink("Edit""Edit"new { id=item.SM_UID }) |  
  3.     @Html.ActionLink("Details""Details"new { id=item.SM_UID }) |  
  4.     @Html.ActionLink("Delete""Delete"new { id=item.SM_UID })  
  5. </td>  

Your application will work fine.

I hope this fix will help you.


Similar Articles