简体   繁体   English

LINQPad over MVC4 WebApi

[英]LINQPad over MVC4 WebApi

I have prepared some code that builds a collection. 我准备了一些构建集合的代码。 I would like to use this collection in LINQPad for various queries. 我想在LINQPad中使用这个集合来进行各种查询。 As LINQPad allows WCF OData I thought that MVC4 WebApi would be perfect for this. 由于LINQPad允许WCF OData,我认为MVC4 WebApi将是完美的。

Unfortunatelly I wasn't able to make this work even with the template WebApi project. 不幸的是,即使使用模板WebApi项目,我也无法完成这项工作。 When I try to add service to LINQPad I get "Data at the root level is invalid. Line 1, position 1. I think the problem is that LINQPad doesn't use content negotiation and it is expecting xml but WebApi returns json. 当我尝试向LINQPad添加服务时,我得到“根级别的数据无效。第1行,位置1.我认为问题是LINQPad不使用内容协商,它期待xml但WebApi返回json。

Unfortunatelly Fiddler wasn't able to monitor the requests. 不幸的是,Fiddler无法监控请求。

Anyone know how to fix this? 有人知道怎么修这个东西吗?

LinqPad does not have the REST drivers by default to query a Web API service. 默认情况下,LinqPad没有REST驱动程序来查询Web API服务。 See: http://forum.linqpad.net/discussion/199/linqpad-error-when-access-odata-using-webapi 请参阅: http//forum.linqpad.net/discussion/199/linqpad-error-when-access-odata-using-webapi

However, the following blog post by Filip W. speaks to this issue and how you can create a custom ControllerResolver that overrides the default resolver and allows running Web API from LinqPad. 但是,Filip W.的以下博客文章谈到了这个问题,以及如何创建一个自定义的ControllerResolver来覆盖默认的解析器并允许从LinqPad运行Web API。 Have a look: 看一看:

Hosting ASP.NET Web API in LinqPad 在LinqPad中托管ASP.NET Web API

This post follows the same question: Using WebAPI in LINQPad? 这篇文章遵循同样的问题: 在LINQPad中使用WebAPI?

why don't you just use the HttpClient class? 你为什么不只使用HttpClient类? HttpClient HttpClient的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM