asp.net-core-webapi

ASP.NET Core with IIS - HTTP Verb Not Allowed

倖福魔咒の 提交于 2019-12-17 09:22:27
问题 We have an ASP.NET Core 2.0 web site that also presents a couple of simple Web API methods for UI enhancement purposes. The Web API calls work as expected when running locally under IIS Express , but when we deploy to our IIS 8.5 production web server, we get the following error when making HTTP DELETE and PUT requests... 405 Method Not Allowed After some web searching, we have found several posts suggesting the removal of the IIS WebDAV module. We have disabled this in IIS (it is our server)

Enable OPTIONS header for CORS on .NET Core Web API

这一生的挚爱 提交于 2019-12-17 09:22:09
问题 I solved this problem after not finding the solution on Stackoverflow, so I am sharing my problem here and the solution in an answer. After enabling a cross domain policy in my .NET Core Web Api application with AddCors, it still does not work from browsers. This is because browsers, including Chrome and Firefox, will first send an OPTIONS request and my application just responds with 204 No Content. 回答1: Add a middleware class to your project to handle the OPTIONS verb. using System

Ember 3.2.2 not routing request to .NET Core 2.1 JSON web API

不打扰是莪最后的温柔 提交于 2019-12-14 03:34:02
问题 I am new to using Ember and have been following an online video tutorial (see weblink below, though its dated as it uses .NET Core 1.0) that demonstrates how to setup a JSON API back-end with an Ember front-end - I am using Visual Studio Code. I have successfully completed the first video and receive responses from the JSON API back-end. However, I am unable to get the second video working by having Ember send a request to the api-back end for data retrieval. I know this because I am

Consuming WEB API REST GET Xamarin Forms

别等时光非礼了梦想. 提交于 2019-12-13 22:40:15
问题 I have a WEB API hosted on a server, there I have a Products table with Name and Description.I already checked for the postman and this is ok, when I try to implement the method in xamarin by visual studio to bring a record by its name and display in a listview I can not. Could someone help me in the code private async void GetProductByName(string Name) { using (var client = new HttpClient()) { txtTest.Text = "http://www.ProdutosAPITest6.hostname.com/api/products"; var URI = txtTest.Text + "/

Don't see object values from ASP.NET Core MVC in Angular 7 http get

半城伤御伤魂 提交于 2019-12-13 20:19:16
问题 I developed an ASP.NET Core 2.0 Web API service and try to use HttpGet method: http://localhost:50223/api/ArtistsLibrary/ListArtists [HttpGet] [Produces("application/json")] [Route("ListArtists")] public JsonResult ListArtists() { var artists = _context.Artists.ToList(); return Json(new { results = artists }); } public class Artist { [Key] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int id { get; set; } public FakeData fake { get; set; } } public class FakeData { [Key]

ASP.NET Core Web Api Middleware Custom Exception

会有一股神秘感。 提交于 2019-12-13 20:14:16
问题 ASP.NET Core Web Api Middleware Converts Custom Exception into Base Exception I have created a custom exception class and use it throw an exception. The middleware catches it but throws base exception instead of custom exception. I am not able to understand why it does not catch custom exception. Custom Exception public class CustomException : Exception { public int HttpStatusCode { get; private set; } public CustomException() { } public CustomException(int httpStatusCode, string message)

How to modify asp.net Identity UI for asp.net core WebAPI with angular

那年仲夏 提交于 2019-12-13 17:09:47
问题 I started learning .net core a few days ago and as a start, I created a .netcore project with an inbuilt angular 8 templates. It has a couple of pages built in angular, like counter and fetches data, etc, but all the Identity-related pages (login, registration, etc) are coming as a plain HTML from the backend. So "my main Concern is making some UI changes in that page". I found out that the identity has been added to the class library and hence not visible in the backend code. and In order to

How to pass an array of int in ASP.NET Core Web API

霸气de小男生 提交于 2019-12-13 16:32:34
问题 I have this Web API method: [Route("api/[controller]")] [ApiController] public class SubjectsController : ControllerBase { [HttpGet("children")] public IActionResult GetAllFromChildren([FromQuery]int[] childrenIds) { // omitted for brevity } } I'm trying to call this via Ajax passing in an query string but I can't seem to get it to work. My Ajax call looks like this: $.ajax({ url: "/api/subjects/children?childrenIds=1&childrenIds=2&childrenIds=3", method: "GET", contentType: "application/json

Launch ASP.NET Core Web-API programmatically

亡梦爱人 提交于 2019-12-13 16:07:37
问题 How do I launch an ASP.NET Core Web-API programmatically from C#? The API should launch after I click on a button in a form. I already added my API to my solution via Add -> Existing Project... but I don't know how to launch it from a different Project. The Web-API is running on .NET Core 2.0 and I want to launch it from a project using .NET Framework 4 回答1: Probably you are looking for something like this(link) dotnet run [-c|--configuration] [-f|--framework] [--force] [--launch-profile] [-

How to handle OPTION header in dot net core web api

一世执手 提交于 2019-12-13 04:23:00
问题 While testing my dot net core web api with ajax call, chrome replaces my get with Option in the request header when i monitor with fiddler. I followed the code here Enable OPTIONS header for CORS on .NET Core Web API and still not working. How do I achieve this? Here is my start up file public void ConfigureServices(IServiceCollection services) { services.Configure<CookiePolicyOptions>(options => { options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = Microsoft