我想使用一個基本的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'? –