asp.net-core-webapi

Install nginx on an existing asp.net core docker container

喜夏-厌秋 提交于 2019-12-22 12:18:06
问题 I'm currently running a docker container for an ASP.NET Core WebAPI project. This web service is currently exposed on port 80. My dockerfile looks like this: FROM microsoft/dotnet:2.1-aspnetcore-runtime ARG source WORKDIR /app EXPOSE 80 COPY ${source:-obj/Docker/publish} . ENTRYPOINT ["dotnet", "testapi.dll"] I'd like to install nginx as a layer between the service and the exposed public network. The final result should be ASP.NET running on port 90 which is internal only and an nginx

How to set default datetime format for .net core 2.0 webapi

血红的双手。 提交于 2019-12-22 11:24:58
问题 Currently in my local. The API is expecting the same formart as in SQL Server database which is yyyy-mm-dd. However when i am deploying the application into production server. The API is expecting the datetime format as yyyy-dd-mm. Is there any way to configure my .net core web api to accept yyyy-mm-dd as default format in every enviroment? 回答1: 100% of the time, If I am using DateTime , I create an interface for it. It just makes life a lot easier when it's time for testing. I believe this

Angular 4 - How to get data from ASP.Net web api

≯℡__Kan透↙ 提交于 2019-12-22 09:27:50
问题 Using the famous Visual Studio 2017 Angular 4 template, I tested the side navbar buttons and could fetch the in-memory data. Then I added to the project, a new ASP.Net Core 2.0 API controller connected to a database using Entity Framework, and got it to run with the 200 HTTP GET result. The controller code: #region TodoController namespace TodoAngularUI.Controllers { [Route("api/[controller]")] public class TodoController : Controller { private readonly SchoolContext _context; #endregion

ExecuteAsyncPost Example in RestSharp.NetCore

血红的双手。 提交于 2019-12-22 05:45:32
问题 I'm working with RestSharp.NetCore package and have a need to call the ExecuteAsyncPost method. I'm struggling with the understanding the callback parameter. var client = new RestClient("url"); request.AddParameter("application/json", "{myobject}", ParameterType.RequestBody); client.ExecuteAsyncPost(request,**callback**, "POST"); The callback is of type Action<IRestResponse,RestRequestAsyncHandler> Would someone please post a small code example showing how to use the callback parameter with

HttpClient PostAsync posting null content

99封情书 提交于 2019-12-22 05:42:05
问题 I have one api calling another. and here is my code which seems to cause ModelState.IsValid = false on the other side of world. var baseUri = new Uri("http://localhost:5001/"): _httpClient.BaseAdress = baseUri; var data = new StringContent(content: model.Tostring(), encoding: Encoding.UTF8, mediaType: "application/json"); var response = await _httpClient.PostAsync("api/product", data); watching Post([FromBody]Product product) on the api being called I just see product=null . changing to Post(

Use appsettings to drive environment specific settings such as UseUrls

放肆的年华 提交于 2019-12-22 05:13:55
问题 When I'm developing locally using VS Code, I'm going to use port 3000 because I'm a hipster. The non-hipsters want it on port 8080 on the server. That's cool, we got this. Microsoft docs give me the following example: public static void Main(string[] args) { var config = new ConfigurationBuilder() .AddJsonFile("hosting.json", optional: true) .AddCommandLine(args) .Build(); var host = new WebHostBuilder() .UseConfiguration(config) .UseKestrel() .Configure(app => { app.Run(async (context) =>

IIS Express, ASP.NET Core - Invalid URI: The hostname could not be parsed

旧城冷巷雨未停 提交于 2019-12-22 04:15:47
问题 Back from my weekend and went to debug my web project which is an ASP.NET Core Web Api. It started giving me an error: Invalid URI: The hostname could not be parsed. I can start a new asp.net core web api project and it debugs fine so I'm pretty sure its something with my configuration for this project. Any ideas? James 回答1: I had the same issue. Just close VS, remove .vs folder, open project once again. Rebuild & Run. It should help. 回答2: I post this answer because many people found my

The JSON value could not be converted to System.Int32

旧巷老猫 提交于 2019-12-21 21:39:44
问题 i want to send data of object to my web api. the api accept a parameter of class,which properties are type of int and string. this is my class: public class deneme { public int ID { get; set; } public int sayi { get; set; } public int reqem { get; set; } public string yazi { get; set; } } this is my json object: { "id":0, "sayi":"9", "reqem":8, "yazi":"sss" } i want the api read the property "sayi" as integer. but because it cant, it gives the error: The JSON value could not be converted to

How to use ASP.NET Core MVC with Angular using Identity Server 4 to connect to web API

。_饼干妹妹 提交于 2019-12-21 20:19:30
问题 I am writing after the response recieved from the post here -------------------------------------- I am in the process of developing an application that has an MVC core app that simply loads the angular application. The angular application will then connect to a Web API to perform CRUD operations. Im aware its possible to use cookie authentication in conjuction with odic hybrid flow to generate a cookie, but not sure how the angular app can get a reference to the access token and renew it

How to use ASP.NET Core MVC with Angular using Identity Server 4 to connect to web API

依然范特西╮ 提交于 2019-12-21 20:19:10
问题 I am writing after the response recieved from the post here -------------------------------------- I am in the process of developing an application that has an MVC core app that simply loads the angular application. The angular application will then connect to a Web API to perform CRUD operations. Im aware its possible to use cookie authentication in conjuction with odic hybrid flow to generate a cookie, but not sure how the angular app can get a reference to the access token and renew it