我是 ASP.net Core 和 Angular 2 的新手。我创建了我的 angular 2 设置,并且工作正常。但是当我尝试点击 My WebApi 时,我无法点击。
namespace Angular2Application8.Controllers
{
[Produces("application/json")]
[Route("api/Hello")]
public class HelloController : Controller
{
StudentContext db = new StudentContext();
[HttpGet]
public string Ghouse()
{
var x = from n in db.StudentMaster
select n;
return "Hello Ghouse";
}
}
}
我正在尝试点击我的控制器 http://localhost:1473/api/Hello/Ghouse
使用[Route("api/[controller]/[action]")]
所有Controllers
所以当你的controller
名字是HelloController
和method
GHouse
您的网址应该是api/hello/ghouse
还要确保您正确配置了路由。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句