Programming Articles

Page 751 of 2547

What is parameter binding in C# ASP.NET WebAPI?

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

Parameter binding in ASP.NET Web API is the process of automatically mapping HTTP request data to controller action method parameters. Web API uses different binding strategies based on the parameter type and can be customized using attributes. Understanding how parameter binding works is essential for building robust Web APIs that can correctly receive and process data from HTTP requests. Default Parameter Binding Rules Web API follows these default rules for parameter binding − Simple types (int, bool, double, string, DateTime, GUID) are bound from the URI (route data or query string) Complex types (custom classes, ...

Read More

How can we test C# Asp.Net WebAPI?

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

Testing ASP.NET Web API involves sending HTTP requests and receiving responses to verify that your API endpoints work correctly. There are several effective methods to test Web APIs, including using Swagger for interactive documentation and testing, and Postman for comprehensive API testing. Let us create a sample StudentController to demonstrate different testing approaches − Student Model namespace DemoWebApplication.Models { public class Student { public int Id { get; set; } public string Name { get; set; ...

Read More

Check if an Array has fixed size or not in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 217 Views

In C#, all arrays have a fixed size once they are created. You cannot change the length of an array after initialization. To check if an array has a fixed size, use the IsFixedSize property, which always returns true for arrays. Syntax Following is the syntax to check if an array has fixed size − bool isFixed = arrayName.IsFixedSize; Using IsFixedSize Property Example using System; public class Demo { public static void Main() { string[] products = new ...

Read More

What is ViewData in ASP .Net MVC C#?

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

ViewData is a dictionary-based container in ASP.NET MVC that enables data transfer from Controller to View. It stores key-value pairs where keys are strings and values are objects, making it a flexible but loosely-typed data transfer mechanism. ViewData is valid only during the current HTTP request and provides one-way communication from controller to view. Since it uses string keys and object values, it requires explicit casting when retrieving data and does not provide compile-time type checking. Syntax Following is the syntax for storing data in ViewData − ViewData["keyName"] = value; Following is the ...

Read More

Removing all entries from the StringDictionary in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 137 Views

The StringDictionary class in C# provides a collection of string key-value pairs. To remove all entries from a StringDictionary, you use the Clear() method, which empties the entire collection in a single operation. Syntax Following is the syntax for removing all entries from a StringDictionary − stringDictionary.Clear(); Parameters The Clear() method takes no parameters and returns void. It removes all key-value pairs from the StringDictionary and sets the Count property to zero. Using Clear() Method Example using System; using System.Collections; using System.Collections.Specialized; public class Demo { ...

Read More

What is the usage of DelegatingHandler in Asp.Net webAPI C#?

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

In ASP.NET Web API, a DelegatingHandler is a type of HTTP message handler that forms a chain of handlers to process HTTP requests and responses. Each handler in the chain can perform operations on the request before passing it to the next handler, and then process the response when it comes back up the chain. The DelegatingHandler class allows you to create custom server-side message handlers that can intercept, modify, or handle HTTP requests and responses globally across your Web API application. This is useful for implementing cross-cutting concerns like logging, authentication, caching, or request validation. Syntax ...

Read More

Removing all nodes from LinkedList in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 253 Views

The LinkedList class in C# provides the Clear() method to remove all nodes from a LinkedList efficiently. This method removes all elements and sets the Count property to zero. Syntax Following is the syntax for the Clear() method − public void Clear() Parameters The Clear() method does not take any parameters. Return Value The Clear() method does not return any value. It modifies the LinkedList by removing all nodes. Using Clear() with Integer LinkedList The following example demonstrates how to remove all nodes from a LinkedList containing integers − ...

Read More

How to add custom message handlers to the pipeline in Asp.Net webAPI C#?

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

To create a custom Server-Side HTTP Message Handler in ASP.NET Web API, we need to create a class that must be derived from the System.Net.Http.DelegatingHandler. Message handlers allow you to intercept HTTP requests and responses, enabling cross-cutting concerns like logging, authentication, caching, or request modification. How Message Handlers Work Message handlers form a pipeline where each handler can process the request before passing it to the next handler, and process the response on its way back. This provides a powerful mechanism for implementing middleware-like functionality in Web API. Message Handler Pipeline ...

Read More

Get an enumerator that iterates through StringCollection in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 205 Views

The StringCollection class in C# provides a GetEnumerator() method that returns a StringEnumerator object. This enumerator allows you to iterate through the collection elements one by one using the MoveNext() and Current properties. Syntax Following is the syntax for getting an enumerator from StringCollection − StringEnumerator enumerator = stringCollection.GetEnumerator(); Following is the syntax for iterating using the enumerator − while (enumerator.MoveNext()) { Console.WriteLine(enumerator.Current); } Using GetEnumerator() with StringCollection The GetEnumerator() method returns a StringEnumerator that provides MoveNext() and Current members for manual iteration − Example ...

Read More

Get or set the element at the specified index in ArrayList in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 1K+ Views

The ArrayList class in C# provides an indexer property that allows you to get or set elements at a specified index using square bracket notation. This property provides direct access to elements by their position in the collection. Syntax Following is the syntax for accessing elements by index in ArrayList − // Get element at index object element = arrayList[index]; // Set element at index arrayList[index] = value; Parameters index − The zero-based index of the element to get or set. value − The object to store at the specified index ...

Read More
Showing 7501–7510 of 25,466 articles
« Prev 1 749 750 751 752 753 2547 Next »
Advertisements