asp.net-web-api

Resource Description on Web API Help page is showing “None.”

风格不统一 提交于 2020-01-02 05:15:13
问题 I'm having trouble figuring out how to get the Help page in my Web Api to show anything for Resource Description other than None. It has IHttpActionResult linked and then "None." after that. I got my samples working by adding config.SetActualResponseType(typeof(ComplexType), "Controller", "Action"); to HelpPageConfig.cs. My controller looks like this: /// <summary> /// My description /// </summary> [Route("MyRoute")] public IHttpActionResult Get() { try { //throw new Exception("TEST"); return

Custom Headers and Signalr: Asp.Net MVC4 Web Api

别说谁变了你拦得住时间么 提交于 2020-01-02 05:00:29
问题 I am using signalr (version 2.0.0) in my asp.net mvc4 webapi project, Here to allow cross origin resource sharing, i use the following code in webconfig file <customHeaders> <add name="Access-Control-Allow-Origin" value="*" /> <remove name="X-Powered-By" /> </customHeaders> Here is the client side signalr code for receiving data from server: $(function () { var nodePublishingHub = $.connection.nodePublishingHub; nodePublishingHub.client.NodePublished = onNewMessage; $.connection.hub.error

Getting “No action was found” from WebApi

偶尔善良 提交于 2020-01-02 04:37:08
问题 I am a WCF dev, new to MVC. Trying to integrate my WCF API as ApiControllers into an MVC application (still big question if it's a worthy effort). I have this request from a jQuery plugin: POST http://localhost:18698/Api/Public/DoAction HTTP/1.1 .... Content-Type: application/json; charset=UTF-8 Accept: application/json, text/javascript, */*; q=0.01 {"myParam":"test"} My controller looks like this: public class PublicController : ApiController { [HttpPost] public string DoAction(string

Duplicate parameter output in Swagger

↘锁芯ラ 提交于 2020-01-02 03:38:04
问题 Update: I'm starting to wonder if this is due to a bug: https://github.com/domaindrivendev/Swashbuckle/issues/590 But the workaround suggested there does not seem to solve my problem. I am using Swashbuckle to generate API documentation for a C# ASP.NET Web API project. My target is to allow the following as valid URL: /endpoint/items/123/foo?param2=bar With a required parameter (param1) set to "foo" and an optional parameter (param2) set to "bar". I would like both parameters contained

OData v4 Function always returns 404

心不动则不痛 提交于 2020-01-02 03:37:10
问题 Trying to move from OData v3 to OData v4 . Why do I keep getting a 404 when trying to use OData Functions ? Web API Config: ODataModelBuilder builder = new ODataConventionModelBuilder(); //etc builder.EntitySet<LocalizableString>("LocalizableStringApi"); //etc var getComparitiveTableFunction = builder.EntityType<LocalizableString>().Collection.Function("GetComparitiveTable"); getComparitiveTableFunction.Parameter<string>("cultureCode"); getComparitiveTableFunction.ReturnsCollection

Returning Void in Async method from WEB API Controller

女生的网名这么多〃 提交于 2020-01-02 02:25:10
问题 I have this async method inside ASP.NET MVC 4 WEB API Controller that I got from this blog: http://www.strathweb.com/2012/04/html5-drag-and-drop-asynchronous-multi-file-upload-with-asp-net-webapi/ public async Task<IList<RecivedFile>> Post() { List<RecivedFile> result = new List<RecivedFile>(); if (Request.Content.IsMimeMultipartContent()) { try { MultipartFormDataStreamProvider stream = new MultipartFormDataStreamProvider(HostingEnvironment.MapPath("~/USER-UPLOADS")); IEnumerable<HttpContent

Specifying custom property name when binding object to Web API endpoint

本小妞迷上赌 提交于 2020-01-02 00:41:10
问题 I have a .Net Core Web API. It automatically maps models when the model properties match the request body. For example, if you have this class: public class Package { public string Carrier { get; set; } public string TrackingNumber { get; set; } } It would correctly bind it to a POST endpoint if the request body is the following JSON: { carrier: "fedex", trackingNumber: "123123123" } What I need to do is specify a custom property to map. For example, using the same class above, I need to be

WebAPI Slow first call to service

不羁的心 提交于 2020-01-01 19:07:06
问题 I was having issues with WCF and slow startup times, so i switched all of my code to use WebAPI. While the startup time has reduced massively (~8-15 seconds down to ~2) I still have an odd latency on startup. Currently its about ~2 seconds but subsequent calls are under 0.5 seconds consistently, until a timeout occurs. I reviewed all of my ApplicationPool settings to ensure there wasn't any startup delays or idle timeout settings. I found this link Very slow first call to web service which

Can't connect to IIS Express remotely from non-Windows machine

梦想的初衷 提交于 2020-01-01 18:59:26
问题 I am working on an ASP.NET application and I'd like the ability to test the application on my (Android) phone and iPad by connecting directly to my local IIS Express development server. I followed the instructions here on setting up IIS Express to allow remote connections. I am now able to view the application from another Windows machine on my local network by visiting http://my-computer-name:my-port-number/ in the browser. However, I am unable to view the application from any other platform

OData v4 on .Net Core 1.1 missing /$metadata

核能气质少年 提交于 2020-01-01 18:57:07
问题 Using .net Core 1.1, with the Microsoft.AspNetCore.OData libraries, I am able to get an OData endpoint working with my simple controller to perform get, $expand, and other queries. However, I can't get it to return the $metadata to be returned. This question ($Metadata with WebAPi OData Attribute Routing Not Working) is for the same problem, however the .Net APIs have changed since this was posted. Is there a setting, flag, or something else I need to enable? This (http://localhost:52315