Nizamuddin Siddiqui

Nizamuddin Siddiqui

1,958 Articles Published

Articles by Nizamuddin Siddiqui

Page 20 of 196

How to use indexers in C# 8.0?

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

Indexers in C# allow objects to be accessed like arrays using the square bracket notation. C# 8.0 introduced the index from end operator (^) which provides a more intuitive way to access elements from the end of a collection or sequence. The ^ operator returns an index that is relative to the end of the sequence, making it the most compact and easiest way to access end elements compared to traditional methods like array.Length - 1. Syntax Following is the syntax for defining an indexer in a class − public returnType this[parameterType parameter] { ...

Read More

What is the use of ChildActionOnly attribute in ASP .Net MVC C#?

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

The ChildActionOnly attribute in ASP.NET MVC C# restricts an action method to be accessible only through child requests from views using Html.Action() or Html.RenderAction() helpers. It prevents direct URL access to the action method, making it ideal for creating reusable partial components. Syntax Following is the syntax for using the ChildActionOnly attribute − [ChildActionOnly] public ActionResult ActionName() { // action logic return View(); } To invoke a child action from a view, use one of these helper methods − @Html.Action("ActionName", new { parameter = value }) ...

Read More

What are Async Streams in C# 8.0?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 250 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 468 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
Showing 191–200 of 1,958 articles
« Prev 1 18 19 20 21 22 196 Next »
Advertisements