-1

過去数日間、答えを探していましたが、アプリを機能させる方法がわかりません。アプリのすべてのサブタブに対して 1 つのコントローラーしかありません。メインコントローラーの下の1つのサブタブに1つのhttp getメソッドがあり、別のサブタブにもメインコントローラーの下にある別のhttp getメソッドが必要です。どうすればそれを行うことができますか?

4

1 に答える 1

0

属性ルーティングを使用できます。

      [HttpGet]
      [Route("method1/{id}")]
      public HttpResponseMessage index(string id) 
     {
        try
        {
           // your code
        }
       catch (Exception ex)
       {
          return Request.CreateResponse(HttpStatusCode.Forbidden,ex.Message);
       }
     }

         [HttpGet]
         [Route("method2/{Id}")]
        public HttpResponseMessage GetData(string GetRecordsById) 
          {
               try
                   {
                  //your code
                    }
               catch (Exception)
                  {
                     throw;
                     }
             }
于 2016-01-09T07:07:40.943 に答える