asp.net-web-api

Why can't I post from my Xamarin Frorms app to my .net core web api

情到浓时终转凉″ 提交于 2020-06-09 05:51:09
问题 I have a post method that sends json to my api. My endpoint works in postman so my problem is in my xamarin post request: async void RegisterUser(object sender, System.EventArgs e) { string URL = "http://blablahblah:51001/register"; HttpClient client = new HttpClient(); var model = new RegisterViewModel { Email = EntryEmail.Text, FirstName = FirstName.Text, LastName = LastName.Text, Password = EntryPasswrd.Text }; var content = JsonConvert.SerializeObject(model); await client.PostAsync(URL,

Recursive mapping in ASP.NET Core API - Tree Structure

笑着哭i 提交于 2020-06-01 05:33:45
问题 I'm making a tree structure. As a result, I want to receive such a structure: [ { name: 'node1', subNodes: [ { name: 'node1-1', subNodes: [], }, { name: 'node1-2', subNodes: [], }, ], }, { name: 'node2', subNodes: [], }, { name: 'node3', subNodes: [ { name: 'node3-1', subNodes: [ { name: 'node3-1-1', subNodes: [], }, { name: 'node3-1-2', subNodes: [], }, ], }, { name: 'node3-2', subNodes: [], } ], }, ]; To do this I created a Api endpoint: [HttpGet] public async Task<IActionResult> GetTree()

Decide enum storage which is uploaded to the server and shared by a Client app and an API

孤人 提交于 2020-05-30 08:42:36
问题 Technology stack : One REST API developed in .Net Core 3.1. Two client apps one in Android and other in iOS Scenario : Store enum value in the database such that when the data is uploaded to the API it makes sense (API can take decisions based on the enum). Option 1 : Store enum as a number and copy it in the API. In this scenario, the enum value would be saved in the DB and transferred to the API. When the API need to use the enum for a condition or some other use, it would use the copy of

.Net Framework dll not working on .Net Standard project

半世苍凉 提交于 2020-05-29 05:02:18
问题 I have referenced the .Net framework ddl to .Net standard 2.0 . It will show me below errors. System.Reflection.ReflectionTypeLoadException: 'Unable to load one or more of the requested types. The given assembly name or codebase, '\bin\Debug\netcoreapp2.1\FirstDataBank.DrugServer.API.dll', was invalid. The given assembly name or codebase, '\bin\Debug\netcoreapp2.1\FirstDataBank.DrugServer.API.dll', was invalid. The given assembly name or codebase, '\bin\Debug\netcoreapp2.1\FirstDataBank

Go To Controller shows “Unable to find a matching controller.” error

落爺英雄遲暮 提交于 2020-05-28 12:02:21
问题 In VS 2015, for my Web.API project, I installed MVC 5 from nuget via npm. This installation added references and generated web.config file under Views folder. I added new Controller with generated CRUD functions. When I right click and go to View on action it goes with no problem. But reverse action does not work. If I navigate to view via browser it works as well. Web app compiles as well. Is there any way for me to fix this navigation problem in VS? Did I forget to add something? Following

ASP.NET Core 3.1 How can I get the controller to use System.Text.Json to serialize and deserialize

喜你入骨 提交于 2020-05-28 08:05:45
问题 I am converting from .NET CORE 2.2 to 3.1. Is it possible to force the controller to use System.Text.Json to serialize and deserialize any incoming request and response? Basically, when the request comes in I want to use System.Text.Json and when a response goes out I want to use System.Text.Json . If yes, how? The reason for doing this is that Microsoft is really pushing this library as the replacement for Newtonsoft.Json as being so much safer and faster. But, I cannot seem to find any

ASP.NET Core 3.1 How can I get the controller to use System.Text.Json to serialize and deserialize

若如初见. 提交于 2020-05-28 08:05:34
问题 I am converting from .NET CORE 2.2 to 3.1. Is it possible to force the controller to use System.Text.Json to serialize and deserialize any incoming request and response? Basically, when the request comes in I want to use System.Text.Json and when a response goes out I want to use System.Text.Json . If yes, how? The reason for doing this is that Microsoft is really pushing this library as the replacement for Newtonsoft.Json as being so much safer and faster. But, I cannot seem to find any

Accessing query string variables sent as POST in HttpActionContext

喜欢而已 提交于 2020-05-27 10:50:44
问题 I'm trying to access a query string parameter that was sent using the POST method (WebClient) to the Web API in ASP.NET MVC 5 (in an overridden AuthorizationFilterAttribute). For Get, I've used the following trick: var param= actionContext.Request.GetQueryNameValuePairs().SingleOrDefault(x => x.Key.Equals("param")).Value; However, once I use POST, this does work and the variable paran is set to null. I think that's because the query string method only applies to the url, not the body. Is

Accessing query string variables sent as POST in HttpActionContext

孤街醉人 提交于 2020-05-27 10:44:43
问题 I'm trying to access a query string parameter that was sent using the POST method (WebClient) to the Web API in ASP.NET MVC 5 (in an overridden AuthorizationFilterAttribute). For Get, I've used the following trick: var param= actionContext.Request.GetQueryNameValuePairs().SingleOrDefault(x => x.Key.Equals("param")).Value; However, once I use POST, this does work and the variable paran is set to null. I think that's because the query string method only applies to the url, not the body. Is

Accessing query string variables sent as POST in HttpActionContext

守給你的承諾、 提交于 2020-05-27 10:43:47
问题 I'm trying to access a query string parameter that was sent using the POST method (WebClient) to the Web API in ASP.NET MVC 5 (in an overridden AuthorizationFilterAttribute). For Get, I've used the following trick: var param= actionContext.Request.GetQueryNameValuePairs().SingleOrDefault(x => x.Key.Equals("param")).Value; However, once I use POST, this does work and the variable paran is set to null. I think that's because the query string method only applies to the url, not the body. Is