【发布时间】:2021-07-29 09:35:03
【问题描述】:
我收到错误提示:
HTTP 404。您正在寻找的资源(或其之一 依赖项)可能已被删除,名称已更改,或者是 暂时不可用。请查看以下 URL 并制作 确保拼写正确。请求的网址: /PCController/进度
PCController 是我的控制器的名称。 这是来自我的控制器:
[HttpGet]
public ActionResult Progress()
{
return View();
}
[HttpPost]
public ActionResult Progress(HttpPostedFile file)
{
try
{
if (file.ContentLength > 0)
{
string _FileName = Path.GetFileName(file.FileName);
string _path = Path.Combine(Server.MapPath("~/Content/PC"), _FileName);
file.SaveAs(_path);
}
ViewBag.Message = "File Uploaded Successfully!!";
return View();
}
catch
{
ViewBag.Message = "File upload failed!!";
return View();
}
}
这是我的观点:
@using (Html.BeginForm("Progress", "PCController", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
<div>
@Html.TextBox("file", "", new { type = "file" }) <br />
<input type="submit" value="Upload" />
@ViewBag.Message
</div>
}
【问题讨论】:
-
这个“/PCController/Progress”我猜控制器不应该在那里,所以它应该像“/PC/Progress”。把你的 routes.config 和类名也放进去。
-
非常感谢!我不应该把控制器放在那里,应该是“PC”。
标签: javascript c# asp.net model-view-controller methods