Monday, June 3, 2024

ASP.Net core Interview Questions

 

How to secure web Api Application in core:

·        Add Authentication and Authorization



·        Secure communication with TLS and Https



·        Validate and Sanitize user inputs



·        Input rate limiting: Limit the number of requests a user or IP address can make within a certain time frame to Prevent DOS attacks

·        Logging and Monitoring

·        Keep software up to date.

What makes .net core platform independent?

Several key factors contribute to .NET Core's platform independence:

1. Intermediate Language (IL):

  • .NET Core code is compiled into an intermediate language (IL) called Common Intermediate Language (CIL). This IL is not specific to any operating system.
  • When you run a .NET Core application, a Just-In-Time (JIT) compiler on the target system translates the IL into machine code optimized for that particular platform (Windows, Linux, macOS).

2. .NET Core Runtime (dotnet):

  • The .NET Core runtime (dotnet) is a set of libraries and tools that provide the environment for executing .NET Core applications.
  • This runtime is available for different operating systems, allowing .NET Core applications to run consistently across them.
  • The runtime includes components for garbage collection, memory management, and other essential services needed for .NET Core applications to function.

3. Core Libraries:

  • .NET Core offers a subset of the full .NET Framework class library, containing core functionalities like file I/O, networking, and data structures.
  • These core libraries are designed to be platform-independent, ensuring consistent behavior across different operating systems.

4. Self-Contained Deployments:

  • .NET Core applications can be self-contained, meaning they include all the necessary dependencies (runtime, libraries) within the application package.
  • This eliminates the need to have a specific version of the .NET runtime pre-installed on the target machine.

5. Alternative Implementations:

  • For functionalities not directly available in the core libraries, .NET Core can leverage platform-specific implementations.
  • For example, on Windows, it might use the native Win32 API for some tasks, while on Linux, it might use POSIX libraries. These platform-specific parts are typically abstracted away from the developer's code.

In summary:

  • The combination of IL, .NET Core runtime availability, core libraries, self-contained deployments, and alternative implementations allows .NET Core applications to be written once and run on various operating systems without significant modifications.

State Management In Asp.net Core?

·        Client Side Validations:

1.      Cookies

2.      Local Storage

3.      Session Storage

4.      Database Storage



3


3. Database Storage:

           

 Difference Between App run and App use?



· app.Run is like the final station where the product is inspected and packaged for shipment. No further processing happens after this point. 

· app.Use is like adding additional stations to the assembly line. Each station performs a specific task on the product before passing it on to the next station. 




How to do Caching in .Net core?

·        In Memory Caching: Microsoft extensions. 

·        




 

 

 


ASP.Net core Interview Questions

 

How to use sessions in Asp.net Core?

1.      Install the Microsoft.AspNetCore.Session NuGet Package

2.      Configure Session Services inStartup.cs

3.      public void configureServices(IServiceConfigurationServices);

{

 services.AddDistributedMemoryCache(); // For in-memory session storage

services.AddSession( option =>

{

  Option.IdleTimeout = TimeSpan.FromMinutes(30);

  Option.cookie.HttpOnly = true;

  Option.cokiee.ISessitial = true;

}

 

)

Inject the ISessionInterface:

public class HomeController: Controller

Public readonly IHttpContextAccessor _httpContextAccessor

public HomeController(IHttpContextAccessor   httpContextAccessor);

{

_httpContextAccessor = httpContextAccessor;

}

httpContextAccessor. HttpContext.Session.SetString( "username" , username);

var username = _httpContextAccessor.HttpContext.Session.GetString( "username" );

Tuesday, April 9, 2024

How to Set up Anaconda for ML and AI

 How to Set up Anaconda for ML and AI

Click on the below link and download free version.

Download Success | Anaconda

and follow the below steps 




It takes few mins to complete the instlation.









Once it is done you need to install some other packages
Open Anaconda Prompt
  • conda install pydotplus 
  • you will get a prompt to countinue click (Y - Enter)
once it is done install tensorflow
pip install tensorflow

It takes a while to complete

If you have any course material and if you want to open in browser
navigate to the folder path  
Add Prompt Jupyter notebook

Sunday, March 24, 2024

How to Set Up Next Js Project In VS code

 Prerequisites:

How to Create New NextJs Project
  • Open Visual Studio Code
  • Select the folder path where you want to create project.
  • Click on Terminal menu on top.
  • It will open to terminal window to run the commands.
  • Run the command -   npx create-next-app@latest
  • You may notice below error:

    npx : The term 'npx' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was 
    included, verify that the path is correct and try again.
    At line:1 char:1
    + npx create-next-app@latest

    If you receive the above Error please make sure that you have installed NodeJS in your system.  You can check the version of node js by command  node -v.

    To resolve: 
    • try to restart VS code
    • npm i -g npx install npx globally. 
    • Try to restart system. 
It will ask for Project Name(please make sure all letters in small case)
  • Type script you want to choose? Click yes and continue
  • √ What is your project named? ... employee-ui
  • √ Would you like to use TypeScript? ... No / Yes
  • √ Would you like to use ESLint? ... No / Yes
  • √ Would you like to use Tailwind CSS? ... No / Yes
  • √ Would you like to use `src/` directory? ... No / Yes
  • √ Would you like to use App Router? (recommended) ... No / Yes
  • √ Would you like to customize the default import alias (@/*)? ... No / Yes
Once it done, It will take a while create project. After that you project folder will be created.

To run the project, navigate to Project root folder. ( Re- open the Project folder which you created). Run the below command
  • npm run dev
Now you will be project is ready , you can check in browser.
http://localhost:3000
 



ASP.Net core Interview Questions

  How to secure web Api Application in core: ·         Add Authentication and Authorization ·         Secure communication with TLS ...