WebApi 使用ASP.NET Web API Help Page

「已注销」 2015-11-05 11:51:09
由于项目中用到了ASP.NET Web API Help Page这个东西,是自动生成插件的。然后我本地测试成功,放到项目里就出问题,压根获取不到那些方法。Help Page里面是用
GlobalConfiguration.Configuration.Services.GetApiExplorer().ApiDescriptions
来获取到那些方法的。经过仔细检查后,发现这完全是因为对象嵌套惹的祸,只要有这样参数的方法,那么该控制器里所有的方法都不能获取到。

这是我写的测试方法
        
/// <summary>
/// 对象类型的Test方法
/// </summary>
/// <param name="p">嵌套参数</param>
/// <returns></returns>
[HttpPost]
public int TestMethod(Parameter p)
{
return 0;
}


这是参数

public class Parameter
{
public int id { set; get; }
public ChildParameter childParameter { set; get; }
}
public class ChildParameter
{
public int iid { set; get; }
}



求各位大神想想办法?或者有用ASP.NET Web API Help Page的大神是怎么解决这个问题的?
...全文
245 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
。net webapi 不好用,不如wcf 它的参数不能随意定义,也可以按照controller/action 这么些,但是人家还不推荐
「已注销」 2015-11-05
  • 打赏
  • 举报
回复
求大神出来啊
This one hundred page book focuses exclusively on how you can best use the ASP.NET MVC 4 Framework to build world-class REST services using the Web API. It sets aside much of what the ASP.NET MVC Framework can do, and focuses exclusively on how the Web API can help you build web services. You will not find any help on CSS, HTML, JavaScript, or jQuery. Nor will you find any help on the Razor view engine, HTML Helpers, or model binding. If you need this information then Pro ASP.NET MVC 4 is your perfect book. ASP.NET MVC 4 and the Web API: Building a REST Service from Start to Finish helps you build cutting-edge REST services using ASP.NET MVC 4 and the Web API in more depth and detail than any other resource. ASP.NET MVC has always been a good platform on which to implement REST, but with the advent of the Web API it has now become even better. This book will show you why it's great and how to get the most from it. Author Jamie Kurtz will take you from zero to full-blown REST service hero in no time at all. And you'll even learn how to incorporate some popular open source tools along the way: little or no experience with ASP.NET or the MVC Framework is required. What you’ll learn How to design a REST API Understanding MVC and Web API controller activation Utilizing open source tools for common tasks Automatic lifetime management for database connections and transactions Easily secure a REST service, using standards-based authentication and authorization How to choose between using WCF or using the Web API Who this book is for This book is written for architects and developers wanting to understand how to quickly and easily build REST services on the ASP.NET platform. No prior knowledge of ASP.NET or MVC Framework is required; however, it assumed you have some experience with the .NET Framework, Visual Studio, and C#. Table of Contents 1. ASP.NET MVC as a Service Framework 2. What is RESTful? 3. Designing Our Sample REST API 4. Building the Environment and Creating the Source Tree 5. Controllers, Dependencies, and Managing the Database Unit of Work 6. Securing the Service 7. Putting It All Together

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧