【问题标题】:asp.net web api long action namesasp.net web api 长动作名称
【发布时间】:2015-05-19 22:03:15
【问题描述】:

我有像这样的长动作名称:

  • GetBestSellerProducts
  • GetBestSellerProductsThisYear
  • GetBestSellerProductsThisYearInCity
  • GetGeaturedProductsWeek

但名称对 api URI 没有用。

  • http://localhost/api/product/GetBestSellerProductsThisYear
  • http://localhost/api/product/GetBestSellerProductsThisYearInCity/225412

有什么实用的方法来分隔小而易读的 URI。

  • http://localhost/api/product/statistics/bestseller/thisyear

【问题讨论】:

    标签: asp.net-mvc asp.net-web-api asp.net-mvc-routing asp.net-web-api-routing


    【解决方案1】:
    [ActionName("Profile")]
    public ActionResult MyProfile()
    

    您可以为此使用 ActionName 属性

    【讨论】:

      猜你喜欢
      • 2013-03-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-02
      • 1970-01-01
      • 1970-01-01
      • 2013-09-10
      • 2021-08-20
      相关资源
      最近更新 更多