[.net mvc] Accept multiple parameters for API in .NET
페이지 정보
작성자 sbLAB 댓글 0건 조회 5,241회 작성일 21-10-08 10:56본문
using Microsoft.AspNetCore.Mvc;
using System;
using VippApi.ApiServices;
namespace VippApi.Controllers
{
[ApiController]
[Route("api/[controller]")]
public class WeatherController : ControllerBase
{
[HttpGet]
public WeatherModel Get(){
return new WeatherModel { Id=1, Value=10};
}
//{"id":1,"value":10}
[HttpGet("{id:int}")]
public WeatherModel GetParam(int id){
return new WeatherModel { Id = id, Value = 20 };
}
//{"id":1,"value":20}
// FromRouteAttribute multiple parameters
[HttpGet("{id}/{first}/{second}")]
public String Details(int id, string first, string second){
return id + "------" + first + "-------" + second;
}
//1------2-------3
[HttpGet("fromquery")]
public String GetParamBothDetails(int id,string backendOnly,string frontendOnly){
return id + "------" + backendOnly + "-------" + frontendOnly;
}
//10------back2-------front3
}
}
Accept multiple parameters for API in .NET
[이 게시물은 sbLAB님에 의해 2022-12-22 09:41:53 Web/PHP/API에서 이동 됨]
- 이전글[.net mvc] ActionResult 21.10.08
- 다음글[Blazor] Blazor *.razor 페이지의 route parameters / Rest Api 21.10.05
댓글목록
등록된 댓글이 없습니다.