我是single page application
中的新人。我在这里创建webapi
:
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.Web.Http.Description;
using WebApplication6.Models;
namespace WebApplication6.Controllers
{
public class ManageStudentInforAPIController : ApiController
{
private SchoolManagementEntities db = new SchoolManagementEntities();
// GET: api/ManageStudentsInfoAPI
public IQueryable<Student> Get()
{
return db.Students;
}
}
}
但是当我调用此网址http://localhost:5411/ManageStudentInforAPI
时,结果是
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /ManageStudentInforAPI
我的问题在哪里。你需要的任何细节我都可以发帖。我正在使用vs2015
答案 0 :(得分:2)
api
之前你错过了ManageStudentInforAPI
。尝试按http://localhost:5411/api/ManageStudentInforAPI
或者您可以将[Route("route")]
添加到控制器或方法中,然后拨打http://localhost:5411/api/route