webapi

Log4Net not logging in .NET WebApi project using UnityContainer

匿名 (未验证) 提交于 2019-12-03 01:23:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a very basic C# .NET WebApi project using Unity.AspNet.WebApi and Unity.Mvc for dependency injection and Unity.log4net for logging. The injection into my controllers seems to be working correctly. The problem is that the logger never logs anything. The expected .log file is never created. When I inspect the logger object while debugging it has all the levels disabled (IsDebugEnable = false, IsErrorEnabled = false, etc.) It is running as if has ignored my log4net.config file. In the root of my project I have a log4net.config file that

Passing array of integers to WebAPI method in URI params?

匿名 (未验证) 提交于 2019-12-03 01:20:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have the following: [HttpDelete] public HttpResponseMessage DeleteFolder(int[] ids) { and I'm trying to use this: DELETE http://localhost:24144/api/folder/1483; DELETE http://localhost:24144/api/folder/[1483] but these are coming up as null within the delete method - how do I send the data without putting it in the body (since this is a DELETE request)? My routing has this: routes.MapHttpRoute( name: "Folder", routeTemplate: "api/folder/{id}", defaults: new { controller = "Folder", id = RouteParameter.Optional } ); 回答1: Nevermind, I found

F#, Json.NET 6.0 and WebApi - serialization of record types

匿名 (未验证) 提交于 2019-12-03 01:14:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: Json.NET 6.0.1 adds F# support for records and discriminated unions. When serializing a F# record type using Json.NET I now get nicely formatted JSON. The serialization is done as follow: let converters = [| ( new StringEnumConverter () :> JsonConverter ) |] JsonConvert . SerializeObject ( questionSet , Formatting . Indented , converters ) However, when I try to expose my F# types through a ASP.NET WebApi 5.0 service, written in C#, the serialized JSON includes an @-sign infront of all properties. The @-sign comes from the internal

Implementing $select with WebApi and ODataQueryOptions

匿名 (未验证) 提交于 2019-12-03 01:12:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to implement some OData functionaility with a custom DAL using ODataQueryOptions. My DAL uses design time generated typed data tables. By intercepting the SelectExpand property of ODataQueryOptions i can get our DAL to only load the columns required. How do i then return just the data required. I am currently tipping the data from our type datatables into a ListOf some typed data tranfer objects but then end up with lots of null data from the columns which aren't required. I feel like i should be able do some LINQ query to select

WebAPI + APIController with structureMap

匿名 (未验证) 提交于 2019-12-03 01:10:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Im trying to use StructureMap to initialize my ValuesController that derivate from ApiController but i'm getting an exception that says: The IControllerFactory '...CustomControllerFactory' did not return a controller for the name 'api'. Here is the code.. public class CustomControllerFactory : DefaultControllerFactory { protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType) { if (controllerType == null) return null; return (Controller)ConcretizationsManager.GetInstance(controllerType); } }

calling SignalR hub from WebAPI controller issues

匿名 (未验证) 提交于 2019-12-03 01:08:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I cannot figure out how I can call into a SignalR hub from a WebAPI ApiController. I have put together a sample you can download here that simplifies the problem and demonstrates the issue. I created a new project from the ASP.NET MVC WebAPI template. I added a new SignalR Hub to the project called ChatHub. Added a HTML page that on load, connects to ChatHub, joins to a group and sends a message to that group. This works great. HTML page also has a button that when clicked will fire an ajax call to the ValuesController's post method. In the

WebAPI ActionName routing half working

匿名 (未验证) 提交于 2019-12-03 01:00:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have been building a WebAPI, trying to route to the right methods with ActionName. It works with one of my methods I try to call, but the other one gets a 404 error. My WebAPI Config file: public static void Register(HttpConfiguration config) { // Web API configuration and services // Configure Web API to use only bearer token authentication. config.SuppressDefaultHostAuthentication(); config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType)); // Web API routes config.MapHttpAttributeRoutes(); config.Routes

Dynamic JavaScript returned by webapi

匿名 (未验证) 提交于 2019-12-03 00:59:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am using requirejs to load JavaScript for my page. I have a webApi route that dynamically reads from a file and returns JSON using the Newtonsoft JObject. On the client side I then take the result and assign it to a local JavaScript variable. define(['jquery'], function ($) { function dynoFile() { $.get('/api/resources/dynofile', function (results) { myNamespace.dynoFile = results; }); } return new dynoFile(); }); This example does work, however it causes problems with other JavaScript files that expect myNamespace.dynoFile to exist. Since

Adjust MVC 4 WebApi XmlSerializer to lose the nameSpace

匿名 (未验证) 提交于 2019-12-03 00:59:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm working on a MVC WebAPI, that uses EF with POCO classes for storage. What I want to do is get rid of the namespace from the XML, so that the endpoints would return and accept xml objects without it. (json works just fine) 22 testas@email.com ... I would like this to work 22 testas@email.com ... Hopefully without having to decorate the POCO's with a bunch of attributes. I've set up a test solution for this, and indeed, these methods are beeing hit (must be some other problem in my system). Anyways - the result that I get using this

Create RSS feed in MVC4/WebAPI

匿名 (未验证) 提交于 2019-12-03 00:58:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I'm looking for the best way to create an RSS feed via MVC4 (and/or WebAPI). This post seemed the most applicable http://www.strathweb.com/2012/04/rss-atom-mediatypeformatter-for-asp-net-webapi/ . But it was written in the pre-Release days of WebAPI. I've used Nuget to bring all packages up-to-date but attempting to build the project tosses: Error 2 The type or namespace name 'FormatterContext' could not be found ( are you missing a using directive or an assembly reference ?) G : \Code\MvcApplication - atomFormatter\MvcApplication