Questions tagged asp.net-web-api

Explore the latest questions and answers asked by our top developers.

My Api is not work from ASP.NET Core with Angular Example Template

I make api from "ASP.NET Core Web Api" Template. And its work, Active PostMan. So I Copy that to "ASP.NET Core with Angular" Template. But Its not work. Just 404 NOT FOUND ERROR. What am I wrong? –Controller …(Skip)… [ApiController] [Route("[controller]")] public class RestaurantController : ControllerBase { private readonly IRestaurantService _service; public RestaurantController(IRestaurantService service) { […]

By Yang
Published
Categorized as angular, asp.net, asp.net-core, asp.net-web-api, c# Tagged , , , ,

Angular – Failed to load resource: the server responded with a status of 404

I have a project with ASP.NET Core Web API backend and Angular-13 frontend. The Web API have this end-point: https://localhost:5001/api/v1/admin/teachers After login, when I pasted the generated bearer token to POSTMAN, it gives this result: { "result": [ { "full_name": "Jamilu Kingston", "account_number": "1234567821", "user_name": "kingston", "mobile_number": "08099889921", } ], "page": 1, "per_page": 10, "total_pages": […]

By midowu
Published
Categorized as angular, asp.net-web-api, jwt Tagged , ,

ASP.NET Core API – Value cannot be null. (Parameter ‘userName’) error in Password Change

I am implementing password change at the user first Login instance using ASP.NET Core Web API as backend and Angular-13 as frontend. For the backend end, I am using Identity DB Context. I have this code: Backend: ASP.NET Core Web API public class MustChangePasswordDto { [JsonProperty(PropertyName = "NewPassword")] public string NewPassword { get; set; } […]

By midowu
Published
Categorized as angular, asp.net-web-api Tagged ,

Angular – How to redirect to Dashboard based on user role

I have a project with ASP.NET Core as backend and Angular-13 as frontend. I have this reponse on POSTMAN when user successfully logs in: { "status_code": 200, "message": "Successfully Logged In", "result": { "token": "gggggffffffffffffdddddddddddd", "user": { "id": 3, "user_name": "smith", "last_login": "2022-01-03T12:35:26.0305649" }, "roles": [ "Teacher" ], } } This is the Angular code: […]

By midowu
Published
Categorized as angular, asp.net-web-api Tagged ,

Angular – ERROR TypeError: Cannot read properties of undefined (reading ‘message’) at AuthComponent.tokenHandler

I have ASP.NET Core Web API as backend and Angular-13 as frontend. When successful, the endpoint on POSTMAN gives: { "status_code": 200, "message": "Successfully Logged In", "result": { "token": "gggggffffffffffffdddddddddddd", "user": { "id": 3, "user_name": "smith", "last_login": "2022-01-03T12:35:26.0305649" }, "roles": [ "Teacher" ], "expires": "2022-01-03T14:40:33Z" } } Then for error, I have: { "statusCode": 500, […]

By midowu
Published
Categorized as angular, asp.net-web-api Tagged ,

Angular – Access to XMLHttpRequest at ‘https://localhost:5001/..’ from origin ‘http://localhost:4200’ has been blocked by CORS policy

In my ASP.NET Core Web API-5, I have this: startup.cs: public void ConfigureServices(IServiceCollection services) { services.AddAppAuthorization(Configuration); } public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IServiceProvider serviceProvider, IApiVersionDescriptionProvider provider) { app.UseCors("AllowAllOrigins"); app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); } } AuthExtension.cs: public static void AddAppAuthorization(this IServiceCollection services, IConfiguration configuration) { // CORS services.AddCors(options => { […]

By midowu
Published
Categorized as angular, asp.net-web-api Tagged ,

Data from Microsoft SQL Server sent to .NET Web API correctly, but not showing up in Angular

My database table looks like this – sample data: Table structure: I am trying to get all the rows to show up on the console of chrome devtools for now. The .NET Web API is shown below; it is working fine I checked in Postman. This is the Entity Framework API controller: using System; using […]

By Devi Suresh
Published
Categorized as .net, angular, asp.net-web-api, sql-server Tagged , , ,

POST api is not getting called even subscribed to?

I have this api public class SendMailController : ApiController { [HttpPost] public bool SendEmail(string UserEmail) } from swagger it is getting called but form angular no Swagger: POST /api/SendMail pass the user email and it is called. http://localhost:55403/api/[email protected] but from angular it doesn’t hit. export class EmailService { constructor(private http: HttpClient) { } sendEmail(userEmail: string) […]

By yalghar ho
Published
Categorized as angular, asp.net-web-api, rest, smtp, typescript Tagged , , , ,

AG-Grid Server Side Pagination paginationChanged Event

I would like to implement AG-Grid with Server side Pagination onGridReady(params) { this.gridApi = params.api; this.gridColumnApi = params.columnApi; if(this.pageNumber == 0) this.pageNumber = 1; var datasource = { getRows: (params: IGetRowsParams) => { params.startRow = this.pageNumber; params.endRow = this.pageSize; this.test.getUsers(params) .subscribe(data => { params.successCallback(data[‘users’], data[‘totalRecords’]) }); } } this.rowData = datasource; this.gridApi.setDatasource(datasource); } onGridReady event […]

Kendo Grid Server Side Paging with Angular 6 – Search in a Query instead of directly from Table

I am using kendo-angular-grid – ^4.8.4 with Angular 6 In the below URL, I am trying to implement Custom Directives to achieve Server Side Paging https://www.telerik.com/kendo-angular-ui/components/grid/data-binding/automatic-operations/ In this for Northwind Service Products table is queried. export abstract class NorthwindService extends BehaviorSubject<GridDataResult> { public loading: boolean; private BASE_URL = ‘https://odatasampleservices.azurewebsites.net/V4/Northwind/Northwind.svc/’; constructor(private http: HttpClient, protected tableName: string) […]

By CPK 2011
Published
Categorized as angular, asp.net-web-api, c#, kendo-grid Tagged , , ,
1 25

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq