我有臭名昭着的Web Api沒有找到與控制器名稱匹配的類型。我有這個網絡服務工作,直到我們做了一些文件系統和類的重組,現在我得到這個錯誤。在訪問來自同一解決方案內的類庫的數據類時,文件系統默認使用控制器和模型文件夾。我的路線沒有改變,所以我不認爲這是一個問題。找不到與控制器名稱匹配的類型
這裏是我的控制器:
namespace CECC.Services.Controllers
{
public class MeterBlinksController : ApiController
{
// Will return all the meters for the date range with blinks >= minimum blinks passed.
public IEnumerable<JsonMeterBlinksModel> GetBlinks(string startDate, string endDate, int meterNumber)
{
return GetBlinksByDateRange();
}
public IEnumerable<JsonMeterBlinksModel> GetBlinksByDateRange()
{
var conn = new Connection();
List<JsonMeterBlinksModel> blinksCollection = new List<JsonMeterBlinksModel>();
string queryString =
"select meteraccts.meternumber, t1.blinks, scemain.subname, feeder.feedername "
+ "from(select serialnumber, sum(blinkcount) as blinks "
+ "from cecc_processed_blinks "
+ "where trunc(blinkdate) between to_date(:startDate, 'dd-mm-yy') and to_date(:endDate, 'dd-mm-yy') group by serialnumber) t1 "
+ "left join meteraccts on t1.serialnumber = meteraccts.serialnumber "
+ "left join serialnumber on t1.serialnumber = serialnumber.serialnumber "
+ "left join scemain on serialnumber.subid = scemain.subid "
+ "left join feeder on serialnumber.subid = feeder.subid and serialnumber.fdrid = feeder.fdrid "
+ "where METERNUMBER is not null and SUBNAME is not null and FEEDERNAME is not null and t1.blinks >= 0 order by t1.blinks desc";
conn.QueryInto<JsonMeterBlinksModel>(ref blinksCollection, queryString, null);
return blinksCollection;
}
這裏是我的路線:
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
,最後,我的錯誤:
{"Message":"No HTTP resource was found that matches the request URI 'http://localhost:36819/api/getblinks'.","MessageDetail":"No type was found that matches the controller named 'getblinks'."}