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

Nizamuddin Siddiqui
Updated on 17-Mar-2026 07:04:36

704 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
Updated on 17-Mar-2026 07:04:36

356 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

Find the Angle Between Hour and Minute Hands of a Clock in C#

AYUSH MISHRA
Updated on 17-Mar-2026 07:04:36

7K+ Views

The calculation of the angle between the hour and minute hands of a clock is a common problem in logical reasoning and programming. This calculation is used in various applications, such as analog clock simulations, scheduling software, and time-based animations. In this article, we will discuss how to calculate the angle between the hour and minute hands of a clock in C# using different approaches. What is the Angle Between the Hour and Minute Hands? The angle between the hour and minute hands is determined based on the positions of both hands on the clock face. Key ... Read More

Get the HashCode for the current UInt32 instance in C#

AmitDiwan
Updated on 17-Mar-2026 07:04:36

177 Views

The GetHashCode() method in C# returns a hash code for the current UInt32 instance. This hash code is used internally by hash-based collections like Dictionary and HashSet for efficient storage and retrieval operations. For UInt32 values, the hash code is typically the value itself, making it straightforward to understand and predict. Syntax Following is the syntax for getting the hash code of a UInt32 instance − uint value = 100; int hashCode = value.GetHashCode(); Return Value The GetHashCode()

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

Nizamuddin Siddiqui
Updated on 17-Mar-2026 07:04:36

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

TimeSpan.FromMinutes() Method in C#

AmitDiwan
Updated on 17-Mar-2026 07:04:36

2K+ Views

The TimeSpan.FromMinutes() method in C# is used to return a TimeSpan that represents a specified number of minutes, where the specification is accurate to the nearest millisecond. This static method is particularly useful when you need to create time intervals based on minute values. Syntax Following is the syntax for the TimeSpan.FromMinutes() method − public static TimeSpan FromMinutes(double value); Parameters value − A double representing the number of minutes, accurate to the nearest millisecond. Can be positive or negative. Return Value Returns a TimeSpan object that represents ... Read More

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

Nizamuddin Siddiqui
Updated on 17-Mar-2026 07:04:36

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

TimeSpan.FromSeconds() Method in C#

AmitDiwan
Updated on 17-Mar-2026 07:04:36

4K+ Views

The TimeSpan.FromSeconds() method in C# is used to return a TimeSpan that represents a specified number of seconds, where the specification is accurate to the nearest millisecond. This static method is particularly useful when you need to create time intervals based on second values. Syntax Following is the syntax for the TimeSpan.FromSeconds() method − public static TimeSpan FromSeconds(double value); Parameters value − A number of seconds, accurate to the nearest millisecond. Can be positive, negative, or zero. Return Value Returns a TimeSpan object that represents the specified number of ... Read More

Get an ICollection containing keys in OrderedDictionary in C#

AmitDiwan
Updated on 17-Mar-2026 07:04:36

204 Views

The OrderedDictionary class in C# maintains the insertion order of elements. To get an ICollection containing keys from an OrderedDictionary, you can use the Keys property which returns an ICollection object containing all the keys in their insertion order. Syntax Following is the syntax to get keys as an ICollection from OrderedDictionary − OrderedDictionary dict = new OrderedDictionary(); ICollection keys = dict.Keys; Using Keys Property with CopyTo Method The most common approach is to use the Keys property and copy the keys to a string array using the CopyTo method − ... Read More

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

Nizamuddin Siddiqui
Updated on 17-Mar-2026 07:04:36

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

Advertisements