Click here to Skip to main content
14,837,944 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am getting a HTTP 404 error in "/Home/Index". If someone could tell me some common MVC HTTP Errors it would be much appreciated.

HomeController.cs
C#
public class HomeController : Controller
{
    private testContext db = new testContext();
    List<Table1> thistable = new List<Table1>();
    [HttpPost]
    public ActionResult Index()
    {
        thistable = db.Data1.ToList();
        ...
        return View(thistable);
     }
}

Index.cshtml
HTML
@model IEnumerable<AllIndexTables.Models.Table1>
<h2>Index</h2>
<center>
    <table>
        @foreach (var item in Model)
        {
            <tr>
                <td>
                    @Html.TextBoxFor(modelItem => item.Idt)
                </td>
                <td>
                    @Html.TextBoxFor(modelItem => item.datetime0)
                </td>
                <td>
                    @Html.TextBoxFor(modelItem => item.col1)
                </td>
                <td>
                    @Html.TextBoxFor(modelItem => item.col2)
                </td>
                <td>
                    @Html.TextBoxFor(modelItem => item.col3)
                </td>
            </tr>
        }
    </table>
</center>
Posted
Updated 2-Feb-15 11:22am
v2

1 solution

404 is page not found - I notice you have a [HttpPost] attribute on your Index action, this means that it will block any HTTP GET requests.

Try removing the [HttpPost] attribute and see if it starts working.
   
Comments
Pranay Rana 3-Feb-15 6:52am
   
no problem i removed my solution.....

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900