Nizamuddin Siddiqui

Nizamuddin Siddiqui

1,958 Articles Published

Articles by Nizamuddin Siddiqui

Page 17 of 196

How to do versioning with accept header in C# ASP.NET WebAPI?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 694 Views

The Accept header in HTTP tells the server what file format the client wants the response data in. These formats are commonly called MIME-types (Multipurpose Internet Mail Extensions). In ASP.NET Web API, you can use the Accept header to implement API versioning by including version information as a parameter in the Accept header. This approach allows you to maintain multiple API versions while using the same URL endpoints, routing requests to different controllers based on the version specified in the Accept header. How Accept Header Versioning Works When a client makes a request, it includes an Accept ...

Read More

How to do versioning with custom media type in C# ASP.NET WebAPI?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 347 Views

API versioning through custom media types allows clients to specify which version of an API they want to use by including version information in the Accept header. This approach uses vendor-specific media types to route requests to the appropriate controller version based on the requested content type. Custom media types follow a pattern like application/vnd.company.resource.version+format, where the version is embedded within the media type identifier itself. Media Type Versioning Pattern The following media types route to different controller versions − application/vnd.demo.students.v1+json → StudentsV1Controller application/vnd.demo.students.v2+json → StudentsV2Controller Custom Media Type ...

Read More

How can we create a LOG filter for Logging purposes in C# ASP.NET WebAPI?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 1K+ Views

Action filters in C# ASP.NET Web API are used to add extra logic before or after action methods execution. The OnActionExecuting and OnActionExecuted methods allow you to inject custom logic at specific points in the request pipeline, making them perfect for logging purposes. A LOG filter helps track API method calls, execution times, and other diagnostic information. This is particularly useful for debugging, performance monitoring, and audit trails in production applications. Syntax Following is the syntax for creating a custom action filter by inheriting from ActionFilterAttribute − public class LogAttribute : ActionFilterAttribute { ...

Read More

What is Shallow Copy and how it is different from Deep Copy in C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 1K+ Views

A shallow copy creates a new object but copies only the reference values from the original object. When the copied object contains reference types, both the original and copied objects point to the same memory locations for those inner objects. A deep copy creates a completely independent copy of an object, including all nested objects. Changes to one object do not affect the other since they occupy separate memory spaces. Shallow Copy vs Deep Copy Shallow Copy ...

Read More

How to make use of both Take and Skip operator together in LINQ C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 3K+ Views

The Take and Skip operators in LINQ C# are powerful tools for data manipulation. The Skip operator skips over a specified number of elements from the beginning of a sequence, while the Take operator returns a specified number of elements from the beginning of a sequence. When used together, Skip and Take enable you to implement pagination and extract specific ranges of data from collections. This combination is particularly useful for scenarios like displaying search results in pages or processing data in chunks. Syntax Following is the syntax for using Skip operator − var result ...

Read More

How to create an array with non-default repeated values in C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 829 Views

We can create an array with non-default repeated values using Enumerable.Repeat(). This method creates a sequence that contains one repeated value a specified number of times. It requires the System.Linq namespace to be included. Syntax Following is the syntax for using Enumerable.Repeat() − IEnumerable Enumerable.Repeat(T element, int count) Parameters element − The value to be repeated in the sequence. count − The number of times to repeat the value in the generated sequence. Return Value Returns an IEnumerable that contains a repeated value. To convert ...

Read More

How to force garbage collection in C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 2K+ Views

The garbage collector in C# automatically manages memory by removing unused objects. However, you can force garbage collection to run immediately using the GC.Collect() method, though this is generally not recommended due to performance implications. Forcing garbage collection should only be used in specific scenarios where you know large amounts of memory have been freed and want to clean up immediately, such as after closing a large document or completing a memory-intensive operation. Syntax Following is the syntax for forcing garbage collection − GC.Collect(); To collect specific generations − GC.Collect(int generation); ...

Read More

How to get the Unix timestamp in C#

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 7K+ Views

A Unix timestamp is a system for describing time as the number of seconds that have elapsed since January 1, 1970, at 00:00:00 UTC. This epoch time is widely used across different operating systems and programming languages for consistent time representation. Unix timestamps are particularly useful for storing dates in databases, comparing times across different time zones, and working with APIs that expect epoch time values. What is Unix Timestamp? The Unix timestamp represents time as a single integer value − the count of seconds since the Unix epoch (January 1, 1970, UTC). This makes it timezone-independent ...

Read More

What is if/then directives for debug vs release in C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 2K+ Views

In C#, conditional compilation directives like #if DEBUG allow you to include or exclude code based on the build configuration. Visual Studio provides two main build configurations: Debug mode for development and debugging, and Release mode for final production builds. The #if DEBUG directive enables code to execute only when compiled in Debug mode. In Release mode, this code is completely excluded from compilation, making it useful for debugging statements, logging, and development-only features. Syntax Following is the basic syntax for conditional compilation directives − #if DEBUG // Code executed only ...

Read More

What are built-in message handlers in Asp.Net webAPI C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 844 Views

A message handler is a class that receives an HTTP request and returns an HTTP response. Message handlers derive from the abstract HttpMessageHandler class and provide us the opportunity to process, edit, or decline an incoming request before it reaches the HttpControllerDispatcher. Message handlers are executed much earlier in the request processing pipeline, making them ideal for implementing cross-cutting concerns in Web API. They form a chain of classes that process HTTP requests and responses through a pipeline. ASP.NET Web API Message Handler Pipeline ...

Read More
Showing 161–170 of 1,958 articles
« Prev 1 15 16 17 18 19 196 Next »
Advertisements