![](/img/trans.png)
[英]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.