HTTP Error 404.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 website and performing any CRUD (Create, Read, Update, Delete) operation. Stackoverflow is full of such queries so I decided to post the fix here. You might not find it useful for your case but I think majority of requests can be satisfied.

Let me show you an error page image here:


Look at the URL in 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 word 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 and so on. Yet in the preceding image we are not supplying the ID.

Let's fix it. Open the 'Index' view of 'demo' controller and look at the existing code:


Oh! there is 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.

Comments

Popular posts from this blog

Migrating database from ASP.NET Identity to ASP.NET Core Identity

Customize User's Profile in ASP.NET Identity System