【发布时间】:2016-04-30 04:33:03
【问题描述】:
CalculatorController
public class CalculatorController : Controller
{
// GET: Calculator
[HttpPost]
public ActionResult Index1(double a, double b, string op="+")
{
switch(op)
{
case "+":
ViewBag.Ketqua = a + b;break;
case "-":
ViewBag.Ketqua = a + b;break;
case "*":
ViewBag.Ketqua = a + b;break;
case "/":
ViewBag.Ketqua = a + b;break;
}
return View();
}
}
索引 1 视图
@{
ViewBag.Title = "Index1";
}
<h2>Index1</h2>
<form name="formcalculator" action="/Calculator/Index1" method="post">
<div>
Nhập a: <input type="text" name="a" size="20" />
<br />
Nhập b: <input type="text" name="b" size="20" />
<br />
<input type="radio" name="op" value="+" /> +
<input type="radio" name="op" value="-" /> -
<input type="radio" name="op" value="*" /> *
<input type="radio" name="op" value="/" /> /
</div>
<div>
<input type="submit" value="Calculator" name="btnOK" />
@ViewBag.Ketqua
</div>
</form>
网址:http://localhost:1524/Calculator/Index1 但是
Server Error in '/' Application.
找不到资源。
描述:HTTP 404。您要查找的资源(或其依赖项之一)可能已被删除、名称已更改或暂时不可用。请查看以下 URL 并确保其拼写正确。
请求的网址:/Calculator/Index1
版本信息:Microsoft .NET Framework 版本:4.0.30319; ASP.NET 版本:4.0.30319.34274
【问题讨论】:
标签: asp.net-mvc-5