Skip to main content

Posts

 Problem : I was writing API in .NET Core 3.1. The API's exported list of custom classes for [httpget] methods from controller. I used Postman for testing the API's. And observed that from code the list of  classes were returned correctly but it were always coming as empty entries in Post man result window. Solution : The class was returning list as Action result. The  native data types like int or string lists were working fine. On further debugging I noticed that the class members were declared public. The get and set modifiers were missing from the class. After adding the get and set methods to the data members of the class. For example: The following code was not working // GET: api/<Controller>         [HttpGet("Sample/Run")]         public async Task<ActionResult> Sampletest()         {             var result = await _datafromDB.GetDaataFromDB();     ...
Recent posts

Online Exam App with .NET Core Web API and Blazor Client

 We will develop an app that can host online exam. It will have the feature to register user, allow the user to log in. Dashboard for creating sample tests.  The code is shared in GIT hub repository https://github.com/ SwagatikaGoswami/ OnlineExamApp.git The database is MySQL database. The server is a WEB API .NET Core service that uses entity framework for DB operations. The client is a web assembly blazor application. The password stored in the database is encrypted. Register window is as follows. It checks for the mandatory fields. The log in page is as follows: The admin dashboard after logging in  The admin dashboard when new test button is clicked. It uses a Blazor component for adding new test samples.

CRUD operation with WCF service and WPF client

 The database restored on local server WCF Service is talking to the database. Used Visual Studio 2019, entity framework 6 for data base operations from the service. The service exposes the following API’s.  The WCF contracts has both synchronous and asynchronous API's The client is in WPF. It has three windows, main window, customer window and order window as follows. The client uses the WCF service for database operations. When customer button is clicked, the customer window is displayed as below. We can perform CRUD operation from it. The customer can be searched based on ID. New customer window The order button launched order window. It has combo box to choose the customer ID. On selecting the ID, the order details are displayed in the data grid as follows. The source code is available in the GIT hub, URL below: https://github.com/SwagatikaGoswami/WPF_WCF_CRUD.git

Default .NET Core Web API stops working on name change

Problem : I create a .Net core web API application using Visual Studio template as follows. I renamed the default controller class “ WeatherForecastController ” to some thing else. My project stopped working. Solution : The solution is to change the at the following places: IN launchSettings And in the controller file, WeatherForecastController.cs  

Web App issue in migrating to Docker Image

Problem: A web service application works fine in IIS Server but does not work if hosted in a docker image in Docker desktop. Analysis: The web service application was using an external software. The dependent software files were not getting copied to the docker image. Hence the web application was failing to do the operation. Solution: The solution was to update the docker file that was generated by Visual Studio while docker support is added. The following changes were made to the docker file to copy the dependent software to the docker image. The files to be copied from the host system also has to be present relative to the docker file. In this case the Model folder is at the same level of the docker file.   FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-nanoserver-1809 AS base WORKDIR /app EXPOSE 80 EXPOSE 443 FROM mcr.microsoft.com/dotnet/core/sdk:3.1-nanoserver-1809 AS build WORKDIR /src COPY ["YourProject.csproj", ""] RUN dotnet restore "./YourProject.c...

Events in .NET

Events A class defines an event member to notify other objects For example, when a Button object is clicked, a Form object receives a notification and performs some action. The CLR’s event model is based on delegates Event member An event member declaration provides the class with three capabilities Objects can register for the event Objects can unregister the event The type that defines the event maintain the set of registered objects and notifies these objects when the event is raised. public event AlarmMessageEventhandler AlarmMessage when viewed in ILDASM, notice that compiler translates the above line to following three constructs private AlarmMessageEventhandler, add_AlarmMessage, remove_AlarmMessage. BurglarSystemManager.cs namespace Event_Demo {     /// <summary>     /// I have declared a class named BurglarSystemManager     /// </summary>     class BurglarSystemManager     {     ...

Real time data to web application using Microsoft Signal R and Razor Pages

Today we are going to learn how to create razor pages and how to send run time value to the razor page using Signal R Create a new .NET core web application Add Signal R library by,  Add Client-Side Library dialog in the project, for Provider select "unpkg" and select the latest version from the drop down For Library, enter @aspnet/signalr@1, Add a new folder to the project named as Hubs The chat hub class inherits from HUb class that manages connections and messaging The send message is called to send the message to all the clients. MyHub.cs file contains the following code using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.SignalR; //using System.Threading.Tasks; namespace SignalRSample.Hubs {     public class MyHub : Hub     {         public async Task SendMessage(string user, string message)         {       ...