.
Net Interview Question
1. hat is authentication and authorization?===>>
W
AuthenticationandAuthorizationare two distinctconcepts used in security.
Authenticationis the process of verifying the identityof a user, device, or system,
such as through a username and password or biometric data (like fingerprints or
facial recognition). Its main purpose is to confirm that the person or entity is who they
claim to be.
Authorization, on the other hand, involves grantingor denying access to resources
or actions based on the authenticated identity, i.e., deciding what the user is allowed
to do. For example, a user may be allowed to view a file but not edit it. So,
authenticationconfirms who you are, whileauthorizationdetermines what you are
allowed to do.
2. hat is middleware?
W
Middlewarein ASP.NET Core is a component that handlesHTTP requests and
responses in a web application's request pipeline. It acts as a processing step that runs
when a request comes into the application, before it reaches a controller or an endpoint, and
can also manipulate the response before it's sent back to the client. Middleware can perform
tasks like logging, authentication, authorization, error handling, and more. To implement
middleware in .NET (C#), you typically create a custom class that defines a method to
process the HTTP request. This method takes in HttpContextas a parameter, allowing
the middleware to interact with the request and response. The custom middleware is then
Configuremethodof the
added to the request pipeline in the Startup.csfile using the
pp.UseMiddleware<T>()method or a simpler built-inmethod like
a app.Usefor short
inline middleware. Here's an example of a simple custom middleware in ASP.NET
ublic class CustomMiddleware
p
{
private readonly RequestDelegate _next;
ublic CustomMiddleware(RequestDelegate next)
p
{
_next = next;
}
ublic async Task InvokeAsync(HttpContext context)
p
{
// Custom logic before the request is processed
Console.WriteLine("Request started");
// Call the next middleware in the pipeline
await _next(context);
// Custom logic after the request is processed
Console.WriteLine("Request finished");
}
}
// In Startup.cs, Configure method
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseMiddleware<CustomMiddleware>(); // Adding custom middleware to the pipeline
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
. App.use and app.run
3
4. Design pattern
5. Routing ⇒attribute,
6. Oops Concept,Overriding and overloading
7. Interface and abstract class
8. What is dbContext?
9. How do you access appsetting value in a project?
10. Error Handling
11. Response codes (401 unauthorized,403 forbidden)
12. What is cors errors ,how to resolve them.
13. Difference between put and patch methods
14. Solid Principle
S:-> Single Responsibility
O=> Open Closed Principle
L=>Liskov Substitution Principle
I=> Interface Segregation
D=> Dependency Inversion
15. SDLC life cycle.
16. Immutable and mutable in c#
17. Shield class
18. Virtual keyword
19. Value type and reference type
20. Csrf prevention
21. What jwt authentication
22. Uri
23. Ref ,Out keyword in C#
24. How restrict to create object of an class
25. What are delegates in C#
26. What is dependency injection ,Ways to implement in di in .net Add scoped ,Add
Transient ,Add
27. Singleton pattern
8. C# Asyc programming awaits keyword
2
29. Task vs thread
30. Object vs Var ,Int vs int
31. In Memory Caching
32. Rest vs restful
33. Rest vs soap
34. Return type of an api
35. How to implement middleware write code and action filter
36. Const and readonly
37. Rest and restful
38. Ways to handle exception
39. Launch setting .json
40. Maximum size transfer through api
41. Put vs post
42. Rate limiting in api
43. Api protection strategies
Programming Question
1. Reverse an string
using System;
lass Program
c
{
static void Main()
{
string str = "hello";
string reversed = "";
for (int i = str.Length - 1; i >= 0; i--)
{
reversed += str[i]; }
Console.WriteLine(reversed); // Output: "olleh"
}
}
2. C
ount Frequency of Character.
using System;
lass Program
c
{
static void Main()
{
string input = "hello world"; // Fixed string
int[] freq = new int[256];
foreach (char c in input) freq[c]++;
onsole.WriteLine("\nCharacter Frequencies:");
C
for (int i = 0; i < 256; i++)
if (freq[i] > 0) Console.WriteLine($"'{(char)i}' -> {freq[i]}");
}
}
.
3 rray Reverse
A
4. Remove 00s from the array.
5. Sort array.
6. Kth some subarray index of given array.
7. Sliding window problem
8. String palindrome
9. Find The Subarray with Largest Sum
Sql Interview Question
1. Remove duplicate from table
2. What is cte ?
3. Difference between function and views
4. Write sp to take first 10 record
create procedure get10Records
As
Begin
Set nocount on;
select top 10 * from test;
end;
exec get10Records
. Difference between primary key and unique key
5
6. Sql injection
7. Difference between inner join and left join
8. ## table and # table
9. Use of set no cout on
10.Indexing in database\
11.Quest related to offset
12.Nth highest salary
13.Left right inner join
14.Varchar vs nvarchar
Feature
VARCH N
VARCH
AR
R
A
Definition S
tores non-Unicode tores Unicode
S
characters characters
haracter
C byte per
1 bytes per
2
Storage character character
nicode
U No Y
es
Support (
UTF-16
)
Performance F
aster, uses less lightly slower due to extra
S
storage storage
est
B nglish and other single-byte
E ultilingual support (Chinese,
M
Used For character languages Arabic, Hindi, etc.)
Syntax Example V
ARCHAR(5
NVARCHAR(
0)
50)
Prefix for String Literals No prefix needed N
'YourText'(Prefix with
N)
ax
M 000 bytes (
8 VARCHAR(MAX) 000 characters (
4 NVARCHAR(MAX)
Size for more) for more)
5.Can use sp in function
1
16.Clustered and not clustered index
17.Union vs union all
18.ON DELETEclause of a
FOREIGN KEYconstraint.Action Behavior
CASCADE Deletes the child rows when the parent row is deleted.
SET NULL Sets the foreign key value in the child table to NULL when the parent
row is deleted.
RESTRICT Prevents the deletion of the parent row if there are any child rows
referencing it.
NO ACTION Similar to RESTRICT, but the check is deferred to the commit point of
the transaction.
SET DEFAULT Sets the foreign key value in the child table to its default value
when the parent row is deleted.
19.
Angular Interview Question
1. How many ways to pass data from one component toanother component.
2. Directives in angular
In Angular,directivesare special instructions inthe DOM that tell Angular how to modify
elements or behaviors.
Types of Directives in Angular
Angular hasthree types of directives:
. C
3 omponent Directives(Most Common)
4. Structural Directives(
*
ngIf *ngFor
, *ngSwitch
, )
5. Attribute Directives(
[ngClass] [ngStyle]
, , CustomDirectives)
. Observable vs promise
6
7. Interceptors in angular
8. Routing in angular
9. Lazy loading in angular
10.Share data between siblings' component code
11.Utility types in angular
12.Decorator in angular
Decorators in Angular
ecorators in Angular arespecial functionsthatmodifyclasses, methods, properties, or
D
parameters. They add metadata and behavior to theseelements.
Types of Decorators in Angular
Angular providesfour main types of decorators:
13.Class Decorators(
@Component @Directive
, @Pipe
, @Injectable
, )
14.Property Decorators(
@
Input @Output
, )
15.Method Decorators(
@
HostListener @HostBinding
, )
16.Parameter Decorators(
@
Inject
)
17.