Nizamuddin Siddiqui

Nizamuddin Siddiqui

1,958 Articles Published

Articles by Nizamuddin Siddiqui

Page 18 of 196

What are Async Streams in C# 8.0?

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

C# 8.0 introduces async streams, which enable asynchronous iteration over data that is generated or retrieved asynchronously. Unlike regular streams that return all data at once, async streams produce elements one at a time as they become available. Async streams use the IAsyncEnumerable interface and allow methods to use yield return with the async modifier. You can consume async streams using await foreach loops, which asynchronously wait for each element. Syntax Following is the syntax for declaring an async stream method − static async IAsyncEnumerable MethodName() { await SomeAsyncOperation(); ...

Read More

What is Content Negotiation in Asp.Net webAPI C#?

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

Content negotiation in ASP.NET Web API is the process of selecting the best format for the response based on what the client can accept. When a client sends a request, it can specify its preferred response format using HTTP headers, and the server responds accordingly. The primary mechanism for content negotiation relies on several HTTP request headers that communicate the client's preferences to the server. HTTP Headers for Content Negotiation Accept − Specifies which media types are acceptable for the response, such as "application/json, " "application/xml, " or custom media types like "application/vnd.example+xml". Accept-Charset − Indicates ...

Read More

What are the advantages of using C# ASP.NET WebAPI?

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

ASP.NET Web API is a framework for building HTTP-based services that can be consumed by a broad range of clients including browsers, mobile applications, and desktop applications. It provides numerous advantages over traditional web services and other communication technologies. Key Advantages of ASP.NET Web API HTTP-Based Architecture Web API works seamlessly with HTTP protocols using standard HTTP verbs like GET, POST, PUT, and DELETE for CRUD operations. This makes it intuitive and follows REST principles − [HttpGet] public IActionResult GetUsers() { } [HttpPost] public IActionResult CreateUser([FromBody] User user) { } [HttpPut("{id}")] ...

Read More

What is the use of Authorize Attribute in C# Asp.Net webAPI?

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

The Authorize attribute in C# ASP.NET Web API is a built-in authorization filter that controls access to API endpoints. It ensures that only authenticated and authorized users can access specific resources, returning HTTP 401 Unauthorized status for unauthenticated requests. Authorization occurs before the controller action method executes, giving you control over who can access your API resources. This attribute can be applied at different levels to provide flexible access control. Syntax Following is the basic syntax for applying the Authorize attribute − [Authorize] public class ControllerName : ApiController { // Controller actions ...

Read More

How to configure C# ASP.NET WebAPI in web.configure file?

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

ASP.NET Web API uses code-based configuration rather than XML-based configuration in web.config. While you cannot configure Web API routing and behavior directly in web.config, you can configure it programmatically in the WebApiConfig.cs file or during application startup. Configuration Location Web API configuration is typically done in the Register method of the WebApiConfig class, which is called during application startup − public static class WebApiConfig { public static void Register(HttpConfiguration config) { // Web API configuration goes here } } ...

Read More

How to consume Asp.Net WebAPI endpoints from other applications using C#?

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

The HttpClient class provides a base class for sending and receiving HTTP requests and responses from URLs. It is a supported async feature of the .NET framework that can process multiple concurrent requests. HttpClient is available in the System.Net.Http namespace and acts as a layer over HttpWebRequest and HttpWebResponse. This article demonstrates how to consume ASP.NET Web API endpoints from external applications using HttpClient. We'll create a Web API with student data and then consume it from a console application. Creating the Web API Student Model First, let's define the Student model − namespace ...

Read More

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

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

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
Showing 171–180 of 1,958 articles
« Prev 1 16 17 18 19 20 196 Next »
Advertisements