如何修复程序中的HTTP 404错误 [英] How do I fix a HTTP 404 error in my program
本文介绍了如何修复程序中的HTTP 404错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在/ Home / Index中收到HTTP 404错误。如果有人能告诉我一些常见的MVC HTTP错误,那将非常感激。
HomeController.cs
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
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
Index.cshtml
@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>
推荐答案
404找不到页面 - 我otice你的Index操作有[HttpPost]属性,这意味着它会阻止任何HTTP GET请求。
尝试删除[HttpPost]属性并查看是否它开始工作。
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.
这篇关于如何修复程序中的HTTP 404错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文