我想使用一个基本的dll文件来计算一个块的体积,并使用asp.net mvc来创建页面。错误:不能隐式地将类型'MyBlock.BlockClass'转换为'System.Web.Mvc.ActionResult'
我有一个窗体,需要三个输入,并在控制器页面有这个代码。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace MvcApplication1.Controllers
{
public class blockController : Controller
{
//
// GET: /block/
public ActionResult Index()
{
return View();
}
[HttpPost]
public ActionResult Index(BlockModel model)
{
if (ModelState.IsValid)
{
MyBlock.BlockClass newVol = new MyBlock.BlockClass(model.Length, model.Width, model.Height);
return newVol;
}
}
}
}
块的dll取三个值的长度,宽度及高度,当我尝试运行它,我得到这个错误
Error 6 Cannot implicitly convert type 'MyBlock.BlockClass' to 'System.Web.Mvc.ActionResult' c:\users\ryan\documents\visual studio 2012\Projects\dad\MvcApplication1\MvcApplication1\Controllers\blockController.cs 25 24 MvcApplication1
其他唯一的代码是从我的视图页面,可以张贴同样,如果它会帮助解决问题,因为我试图显示BlockClass的结果。
你为什么不回来了'View'? –