asp.net-core-webapi

Dependencies of Hangfire client code at Hangfire Server while executing the job fetched from db

ⅰ亾dé卋堺 提交于 2020-01-30 11:31:10
问题 I am using Hangfire to trigger a task daily. I have made two solutions. One for Hangfire Client and another for Hangfire Server. The task is to make a call to another API. When I run this Hangfire client, it is adding the job to MongoDB Successfully. But when Server solution is ran, It is throwing an error : Could not load file or assembly 'schedulingclient.Web, Culture=neutral, PublicKeyToken=93cadf9107ebec2e'. The system cannot find the file specified. scheduling client is the API and also

generic methods for API controller

☆樱花仙子☆ 提交于 2020-01-30 05:44:29
问题 I'm writing an API for my game and I'm starting to realize that the amount of GET, POST, and PUT API methods can really add up. So right now, I'm trying to make it more generic so that I don't have to write a separate method like GetMonsterList, GetTreasureList, GetPlayerInfo, etc. But I'm not quite sure how to go about doing that. Here is a non-generic PUT method that I currently have. // PUT: api/MonsterLists/5 [HttpPut("{id}")] public async Task<IActionResult> PutMonsterList(string id,

Asp.Net Core 3 Web API Identity

非 Y 不嫁゛ 提交于 2020-01-25 08:03:08
问题 I have been stock for 3days now with no possible solution online with this error System.AggregateException HResult=0x80131500 Message=Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: Microsoft.AspNetCore.Identity.ISecurityStampValidator Lifetime: Scoped ImplementationType: Microsoft.AspNetCore.Identity.SecurityStampValidator`1[MyTrBox_WebAPI.Model.User]': Unable to resolve service for type 'Microsoft.AspNetCore.Authentication

Session State being cleared or lost after one AJAX call to .NET CORE 2.1 application hosted on IIS server

ε祈祈猫儿з 提交于 2020-01-25 06:51:08
问题 I have run into this problem for which I have been scratching my head for hours now. The problem: The Session State that I create on Login gets mysteriously cleared or lost after calling an API controller which is also in .NET CORE 2.1. This happens when I call a API method that looks like: [Authorize(Policy = "AdminViewPolicy")] [HttpGet("GetAllUsersId")] public IActionResult GetAllUsersId() { var user = _userService.GetAllUsersId(); return Ok(new { data = user }); } The roles and other

Set XML as default output format in ASP.NET Core 2.0

两盒软妹~` 提交于 2020-01-25 04:48:25
问题 I have added XmlFormaterExtensions like below code which works fine with an Accept header. My query is: How do I set XML as default o/p format instead of JSON? Is there any trick to set the XML for-matter to Camel Case instead of Pascal Case I am using ASP.NET Core 2.0 (Asking for o/p format only) public void ConfigureServices(IServiceCollection services){ services.AddMvc() .AddXmlFormaterExtensions() .AddJsonOptions(options => { options.SerializerSettings.ContractResolver = new

How to make GET request with a complex object?

若如初见. 提交于 2020-01-25 03:50:31
问题 I try to make GET request via WebApi with complex object. Request is like this: [HttpGet("{param1}/{param2}")] public async Task<IActionResult> GetRequest(string param1, int param2, [FromBody] CustomObject[] obj) { throw new NotImplementException(); } Where CustomObject is: [DataContract] public class CustomeObject { [DataMember] public string Name { get; set; } [DataMember] public string Email { get; set; } } How do I compose a valid GET request? 回答1: [FromBody] CustomObject[] obj ... GET

How can I post image from UWP to .NET core web api?

谁都会走 提交于 2020-01-24 20:06:53
问题 Now I have configured for UWP photo post to web api part which is using HttpClient. Uri uri = new Uri("http://localhost:50040/api/Upload"); IInputStream inputStream = await photoFile.OpenAsync(FileAccessMode.Read); HttpMultipartFormDataContent multipartContent = new HttpMultipartFormDataContent(); multipartContent.Add(new HttpStreamContent(inputStream), "myFile", photoFile.Name); Windows.Web.Http.HttpClient newclient = new Windows.Web.Http.HttpClient(); Windows.Web.Http.HttpResponseMessage

ShouldSerialize method is not triggered in .NET Core 3

感情迁移 提交于 2020-01-24 15:09:25
问题 I normally use ShouldSerialize to exclude properties that have no data such as array but now, it does not appear to be triggered when I'm only using JSON serializer in .NET Core 3 . It was being triggered when using NewtonSoft but I've removed it from my project since it no longer appears to be required. For example: private ICollection<UserDto> _users; public ICollection<UserDto> Users { get => this._users ?? (this._users = new HashSet<UserDto>()); set => this._users = value; } public bool

How To Deploy Angular And .NET Core Web API On IIS?

荒凉一梦 提交于 2020-01-24 03:29:14
问题 We have two web sites on IIS for both angular_client and web_api, the hosting bundle is installed and the permission to users such as IUSR, Network, Network Service and Everyone, is already granted. The navigation to each site seperately works, i.e in the API, the call http://localhost:51975/api/user, results in list of all users. The problem is that Angular login page fails to communicate with the API to authenticate users: OPTIONS http://localhost:51975/api/user/authenticate net::ERR

Is there a way to reset $id in JSON response for each HTTP Request?

◇◆丶佛笑我妖孽 提交于 2020-01-24 00:26:08
问题 XYZController.cs [HttpPost] public async Task<ActionResult> Post([FromBody] T inputContext) { var outputContext = Process(inputContext); return StatusCode(200, outputContext ); } Startup.cs public void ConfigureServices(IServiceCollection services) { services.AddMvc().AddJsonOptions(options => { UpdateJsonSettings.ConfigureJsonFormatter(options.SerializerSettings); }); } UpdateJsonSettings.cs internal static void ConfigureJsonFormatter(JsonSerializerSettings settings) { settings