简体   繁体   中英

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. As LINQPad allows WCF OData I thought that MVC4 WebApi would be perfect for this.

Unfortunatelly I wasn't able to make this work even with the template WebApi project. 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.

Unfortunatelly Fiddler wasn't able to monitor the requests.

Anyone know how to fix this?

LinqPad does not have the REST drivers by default to query a Web API service. See: 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. Have a look:

Hosting ASP.NET Web API in LinqPad

This post follows the same question: Using WebAPI in LINQPad?

why don't you just use the HttpClient class? HttpClient

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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