Category "asp.net-web-api"

How to modify port in .Net framework web api

I write a demo program, to use .NET Framework Web Api2. For some reason, I have to use .NET Framework rather than .Net Core. But I've got a problem, how to modi

How to Publish dotnet webapi application that have mutiple projects to iis

[![this is my webApi project solution structure.this have multiple projects added][1]][1] how can i publish these kind of projects in visual studio 2019 [1]: ht

[Authorize(Roles="xx") seems no working in asp.net web api

I am working with an ASP.NET web API project (not .NET Core). I want to add [Authorize(Roles="xx") to my controller action. But it seems not working (always 401

Could not load file or assembly 'Microsoft.IdentityModel.Tokens, Version=5.2.0.0

I am trying to add OWIN JWT into webapi project using VS 2015. The reference shows Microsoft.Owin.Security.Jwt, Version=4.0.0.0 and Microsoft.IdentityModel.Toke

EF Core one-one relationships

I need to configure following one-one relationship with ef-core public class Player { public long Id { get; set; } public string Name { get; set; }

How to check if a property is $select-ed?

I am building an OData web API, and I am trying to implement this function to determine whether a given property should be included in a GET response based on t

ASP.NET Core Web API - Cannot instantiate implementation type 'System.Net.Http.IHttpClientFactory' for service type

I am trying to use Dependency Injection to register service in ASP.NET Core-6 Web API. I got this interface: public interface IHttpClientService { Task<T

Issue after deploying ASP.NET Web API to production

I tested ASP.NET Web API in local environment with IIS Express and on other server with full IIS. At both places, token api and post api is working fine. I am u

Fluent Validation to check just ID property

I am using Fluent Validation in my project. I have one validator class. public class CarValidator : AbstractValidator<Car> { public CarValidator()

ASP.NET Core Web API - 'IRuleBuilderInitial<CustomerTransactionRequestDto, decimal>' does not contain a definition for 'CustomCurrency'

Validation is done in ASP.NET Core-6 Web API using Fluent Validation. So, I have this code: Custom Validator: public static IRuleBuilder<T, string> Custom

How to return HttpStatusCode 404 for incorrect url with FallbackPolicy set in AuthorizationOptions?

In the web application I'm currently working on there is a requirement for all users to be authenticated. This is currently handled by using an AuthorizeFilter.

Calling Another Project's Controller From A Project In The Same Solution (.NET Core )

There are 2 projects in the same solution. First project is a .NET Core project and it has all the codes(controllers, models etc.) related to packages. I need t

How to host a web API in a windows service?

I have created and started a windows service (with exe as MyService.exe) using C# on the other hand I follow up this link for self-hosting: https://codeopinion.

How to implement a client_credentials grant type in an angular http request?

I've created an OAUTH2 authorization server which uses client credentials for authentication and is responsible for the issuing of JWT tokens. When I place my

ASP.Net Core Web API ModelState unvalidated when Dictionary used in FromQuery

I have a GET endpoint which accepts a few parameters and a Dictionary in the Query. public IActionResult Get([FromQuery] RequiredFields required, [FromQuery] D

C# WEB API CORS does not work

Fighting with CORS. I have a site that is making a simple XmlHttpRequest to a WEB API I built in C#. var xhr = new XMLHttpRequest(); xhr.open("GET","h

Create WSDL for an ASP.Net Core ApiController

I am creating a service using ASP.Net Core. The service is based on the ApiController. [ApiController] public class XmlALaCarteServiceController : ControllerBa

IFormFile always return null in asp.net core 2.1

Here's how I upload file my Api action : [HttpPost] public async Task<BaseListResponse<MediaStorageModel>> MediaBrand(IFormFile file, int brandId)

FromBody string parameter is giving null

This is probably something very basic, but I am having trouble figuring out where I am going wrong. I am trying to grab a string from the body of a POST, but

Sending Email Using SMTP Bluehost Server

I use ASP.NET WEB API and I want to send an email from my application from an email created by https://www.bluehost.com/ Here is the configuration in the web