[.net mvc] Accept multiple parameters for API in .NET > C#/.Net/Blazor/IIS

본문 바로가기
사이트 내 전체검색

C#/.Net/Blazor/IIS

[.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=1Value=10};            
        }

        //{"id":1,"value":10}


        [HttpGet("{id:int}")]
        public WeatherModel GetParam(int id){
            return new WeatherModel { Id = idValue = 20 };

        }
        //{"id":1,"value":20}


        // FromRouteAttribute multiple parameters 
        [HttpGet("{id}/{first}/{second}")]
        public String Details(int idstring firststring 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


https://stackoverflow.com/questions/50546703/accept-multiple-parameters-for-api-in-net-core-2-0-using-attribute-routing 

[이 게시물은 sbLAB님에 의해 2022-12-22 09:41:53 Web/PHP/API에서 이동 됨]

댓글목록

등록된 댓글이 없습니다.

회원로그인

접속자집계

오늘
238
어제
291
최대
1,279
전체
223,506

그누보드5
Copyright © sebom.com All rights reserved.