У меня есть простой API, написанный на MVC 4, когда я запускаю его, пишу адрес, он не достигает контроллера:
вот мой контроллер:
public IEnumerable<tenMinsStatcs> Get()
{
string id="192.168.39.32";
string dttimeFrom="05082019";
string dttimeTo="08082019";
string format = "ddMMyyyy";
DateTime fromdate = DateTime.ParseExact(dttimeFrom, format, CultureInfo.InvariantCulture);
DateTime todate = DateTime.ParseExact(dttimeTo, format, CultureInfo.InvariantCulture);
TestClasscs ts = new TestClasscs();
ts.m_turbine_id = IPAddress.Parse("192.168.39.82");
ts.m_time_stamp = Convert.ToDateTime("2019-08-07 5:20:30");
ts.m_wind_speed = 5;
ts.norm_wind_max = 3;
ts.norm_wind_min = 2;
ts.norm_wind_speed = 3;
ts.norm_wind_speed_without_ntf = 1;
List<TestClasscs> myTur = new List<TestClasscs>();
myTur.Add(ts);
// mm.m_time_stamp = Convert.ToDateTime("2019-08-07");
//// mm.m_turbine_id = "192.168.39.84";
// tst.Add(mm);
IPAddress turip = IPAddress.Parse(id);
// var rslt = _context.tenmins.Where(s => s.m_turbine_id ==turip && s.m_time_stamp >= DateTime.Now.AddDays(-1)).Take(2).ToList();
var rslt = (from m in _context.stat10
where m.m_turbine_id == turip && m.m_time_stamp >= fromdate && m.m_time_stamp <= todate
select new tenMinsStatcs
{
m_time_stamp = m.m_time_stamp,
// m_turbine_id = m.m_turbine_id.ToString(),
m_wind_speed = m.m_wind_speed
}).ToList();
return rslt;
}
вотмой webApiConfig:
public static void Register(HttpConfiguration config)
{
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
// Uncomment the following line of code to enable query support for actions with an IQueryable or IQueryable<T> return type.
// To avoid processing unexpected or malicious queries, use the validation settings on QueryableAttribute to validate incoming queries.
// For more information, visit http://go.microsoft.com/fwlink/?LinkId=279712.
//config.EnableQuerySupport();
// To disable tracing in your application, please comment out or remove the following line of code
// For more information, refer to: http://www.asp.net/web-api
config.EnableSystemDiagnosticsTracing();
}
есть идеи, где я делаю неправильно? когда я запускаю свой код, после localhost я пишу api / Values, учитывая, что он должен достичь контроллера, верно?