[英]how to develop simple web api using ASP .net core webapi?
[英]How to set url as webapi in the .net core web?
在Web应用程序中,我创建了一个Page:DetailPage
public void OnGet(int id)
{
var bll = new BLL.Articles();
Item = bll.GetModel(id);
if (Item == null)
{
RedirectToPage("Blogs");
}
}
网址是
localhost/Detail?id=1
我可以将其作为Web API URL,例如`
localhost/Detail/1
我添加了[HttpGet("id")]
但是没有按预期工作。
您可以将它添加到*.cshtml
页面的顶部:
@page "{id:int}"
然后在您的详细信息页面:
public void OnGet([FromRoute] int id)
无需修改Startup.cs
文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.