Reader Level:
ARTICLE

HTTP Error 404.0 0 Not Found in MVC

Posted by Abhimanyu K Vatsa Articles | ASP.NET MVC September 17, 2012
The error "HTTP Error 404.0 - Not Found" in MVC is a common error we get while running websites and performing any CRUD operation. I attempt to describe the fix here that will satisfy most requests.
  • 1
  • 0
  • 12107

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:

        <td>

            @Html.ActionLink("Edit""Edit"new { id=item.SM_UID }) |

            @Html.ActionLink("Details""Details"new { id=item.SM_UID }) |

            @Html.ActionLink("Delete""Delete"new { id=item.SM_UID })

        </td>

 

 

Your application will work fine. 

I hope this fix will help you.

COMMENT USING

Trending up