当我在Angular代码中调用$ http.get('/ api / calendarevent / getall')时,我的API控制器中与该路由匹配的方法的断点未被命中。我不知道这是否意味着控制器中的方法没有被调用,或者它是否绕过了方法中设置的断点。在IE Developer工具中,我收到500错误代码。所以该方法正在被发现,但我不确定它是否正在执行,因为如果没有找到它我会收到某种400错误。下面,我已经包含了必要的代码,任何人都可以看到我可能出错的地方吗?
Angular Code:
protected void Application_Start(object sender, EventArgs e)
{
AreaRegistration.RegisterAllAreas();
RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapHttpRoute(
name: "Default",
routeTemplate: "api/{controller}/{action}/{id}",
defaults: new { id = System.Web.Http.RouteParameter.Optional });
}
的Global.asax.cs:
public class CalendarEventController : ApiController
{
[HttpGet]
[ActionName("all")]
public object GetAll()
{
using (var entity = new RPOEntities())
{
CalendarEventViewModel returnModel = new CalendarEventViewModel();
var events = entity.CalendarEvents.Where(e => !e.Deleted);
var eventList = events.ToList();
var calendarEvents = eventList.Select(e => new
{
id = e.CalendarEventId,
title = e.Title,
start = e.StartDate,
end = e.EndDate,
url = "details/" + e.CalendarEventId.ToString(),
contact = e.Contact,
location = e.Location,
property = e.AllProperties ? "All Properties" : e.Property != null ?
e.Property.PropertyName : "",
active = e.Active,
canEdit = Helper.IsRPOAdmin || Helper.IsCorporateAdmin || (e.PropertyStaffId.HasValue && e.PropertyStaffId.Value == Helper.CurrentUserId)
}).ToList();
return new {
events = calendarEvents,
color = "",
textColor = "" };
}
}
APIController:
for(int i=0;i<10;i++){ //for the rows
for(int j=0;j<5;j++) { //for the columns
table[i][j] = (5 * i) + j ; // This is my addition!!!
System.out.print(table[i][j] +k+ "\t");
}
System.out.println("");
}
}