<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Abhi Gupta on Medium]]></title>
        <description><![CDATA[Stories by Abhi Gupta on Medium]]></description>
        <link>https://medium.com/@heyabhi?source=rss-19972e292f2d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stories by Abhi Gupta on Medium</title>
            <link>https://medium.com/@heyabhi?source=rss-19972e292f2d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 07:45:41 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@heyabhi/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[HTTP QUERY Method in .NET: Send Complex JSON Without Using GET]]></title>
            <link>https://heyabhi.medium.com/http-query-method-in-net-send-complex-json-without-using-get-5ebf1334fbb0?source=rss-19972e292f2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/5ebf1334fbb0</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[dotnet-core]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[tech]]></category>
            <dc:creator><![CDATA[Abhi Gupta]]></dc:creator>
            <pubDate>Fri, 10 Jul 2026 07:11:53 GMT</pubDate>
            <atom:updated>2026-07-10T07:11:53.320Z</atom:updated>
            <content:encoded><![CDATA[<p>For years, developers have faced a common challenge:</p><ul><li><strong>GET</strong> requests are intended for retrieving data.</li><li>Complex filters don’t fit well in query strings.</li><li>While some servers accept a body with GET, the HTTP specification doesn’t define semantics for it, and many proxies, frameworks, and clients ignore or reject GET request bodies.</li></ul><p>To solve this, the IETF introduced the <strong>HTTP </strong><strong>QUERY method</strong> in <strong>RFC 9562</strong>.</p><p>The QUERY method allows clients to perform <strong>safe</strong>, <strong>idempotent</strong> read operations while sending a <strong>request body</strong>, making it ideal for complex search and filtering scenarios.</p><h3>Why Not Use GET?</h3><p>Imagine searching products with multiple filters.</p><p>Using GET:</p><pre>GET /api/products?category=Laptop&amp;brand=Dell&amp;minPrice=500&amp;maxPrice=1500&amp;colors=Black,Silver&amp;features=Touchscreen,BacklitKeyboard</pre><p>As the number of filters grows, URLs become:</p><ul><li>Difficult to read</li><li>Limited by URL length</li><li>Hard to maintain</li><li>Difficult to cache consistently</li></ul><p>Instead, the QUERY method lets you send structured JSON.</p><pre>QUERY /api/products<br>Content-Type: application/json</pre><pre>{<br>  &quot;category&quot;: &quot;Laptop&quot;,<br>  &quot;brands&quot;: [&quot;Dell&quot;, &quot;HP&quot;],<br>  &quot;price&quot;: {<br>    &quot;min&quot;: 500,<br>    &quot;max&quot;: 1500<br>  },<br>  &quot;features&quot;: [<br>    &quot;Touchscreen&quot;,<br>    &quot;Backlit Keyboard&quot;<br>  ],<br>  &quot;sortBy&quot;: &quot;price&quot;,<br>  &quot;page&quot;: 1,<br>  &quot;pageSize&quot;: 20<br>}</pre><p>This is much cleaner and easier to extend.</p><h3>What Is HTTP QUERY?</h3><p>The QUERY method is defined in <strong>RFC 9562</strong>.</p><p>Characteristics:</p><ul><li>Safe (does not modify server state)</li><li>Can contain a request body</li><li>Supports complex JSON payloads</li><li>Better suited for advanced search operations than GET with long query strings</li></ul><p>Unlike POST, the intent is explicitly <strong>reading data</strong>, not creating or updating resources.</p><h3>.NET Client Example</h3><p>.NET 9 introduces a predefined HttpMethod.Query.</p><pre>using System.Net.Http.Json;</pre><pre>var filter = new<br>{<br>    category = &quot;Laptop&quot;,<br>    brands = new[] { &quot;Dell&quot;, &quot;HP&quot; },<br>    minPrice = 500,<br>    maxPrice = 1500<br>};</pre><pre>var request = new HttpRequestMessage(HttpMethod.Query, &quot;/api/products&quot;)<br>{<br>    Content = JsonContent.Create(filter)<br>};</pre><pre>var response = await httpClient.SendAsync(request);</pre><pre>var products = await response.Content.ReadFromJsonAsync&lt;List&lt;Product&gt;&gt;();</pre><p>This sends a QUERY request with a JSON body.</p><h3>ASP.NET Core API Example</h3><p>Create the request model.</p><pre>public class ProductSearchRequest<br>{<br>    public string? Category { get; set; }</pre><pre>    public List&lt;string&gt; Brands { get; set; } = [];</pre><pre>    public decimal? MinPrice { get; set; }</pre><pre>    public decimal? MaxPrice { get; set; }</pre><pre>    public int Page { get; set; }</pre><pre>    public int PageSize { get; set; }<br>}</pre><p>Map a QUERY endpoint.</p><pre>app.MapMethods(&quot;/products&quot;, new[] { &quot;QUERY&quot; },<br>    async ([FromBody] ProductSearchRequest request) =&gt;<br>{<br>    // Perform database search</pre><pre>    return Results.Ok(new<br>    {<br>        Request = request,<br>        Total = 25<br>    });<br>});</pre><p>Example request:</p><pre>QUERY /products<br>Content-Type: application/json</pre><pre>{<br>    &quot;category&quot;:&quot;Laptop&quot;,<br>    &quot;brands&quot;:[&quot;Dell&quot;,&quot;HP&quot;],<br>    &quot;minPrice&quot;:500,<br>    &quot;maxPrice&quot;:1500,<br>    &quot;page&quot;:1,<br>    &quot;pageSize&quot;:20<br>}</pre><p>Example response:</p><pre>{<br>    &quot;request&quot;: {<br>        &quot;category&quot;: &quot;Laptop&quot;,<br>        &quot;brands&quot;: [<br>            &quot;Dell&quot;,<br>            &quot;HP&quot;<br>        ],<br>        &quot;minPrice&quot;: 500,<br>        &quot;maxPrice&quot;: 1500,<br>        &quot;page&quot;: 1,<br>        &quot;pageSize&quot;: 20<br>    },<br>    &quot;total&quot;: 25<br>}</pre><p>One important note: <strong>HttpMethod.Query is available in .NET 9</strong>. If you&#39;re targeting <strong>.NET 8 or earlier</strong>, you can still send a QUERY request using:</p><pre>var request = new HttpRequestMessage(new HttpMethod(&quot;QUERY&quot;), &quot;/products&quot;);</pre><p>This uses the custom HTTP method name until the built-in HttpMethod.Query is available.</p><h3>QUERY vs GET vs POST</h3><p>FeatureGETQUERYPOSTSafe✅✅❌ UsuallyRequest Body❌ Not defined by the HTTP spec✅✅Complex JSON❌✅✅Resource Modification❌❌✅ UsuallyIdeal for SearchLimited✅ ExcellentPossible but semantically less accurate</p><h3>When Should You Use QUERY?</h3><p>Use the QUERY method when:</p><ul><li>You need to send complex search criteria.</li><li>Your filters are too large for a URL.</li><li>The operation is read-only.</li><li>You want HTTP semantics that clearly express a safe query operation.</li></ul><p>Avoid using QUERY for create, update, or delete operations.</p><h3>References</h3><ul><li>RFC 9562 — HTTP QUERY Method: <a href="https://www.rfc-editor.org/rfc/rfc9562">https://www.rfc-editor.org/rfc/rfc9562</a></li><li>ASP.NET Core HTTP APIs: <a href="https://learn.microsoft.com/aspnet/core/fundamentals/apis">https://learn.microsoft.com/aspnet/core/fundamentals/apis</a></li><li>HttpClient in .NET: <a href="https://learn.microsoft.com/dotnet/fundamentals/networking/http/httpclient">https://learn.microsoft.com/dotnet/fundamentals/networking/http/httpclient</a></li></ul><h3>Conclusion</h3><p>The new HTTP QUERY method fills a long-standing gap in HTTP by allowing safe, read-only requests with a request body. Instead of overloading POST for searches or forcing complex data into query strings, QUERY provides a standards-based approach for expressive search APIs.</p><p>With .NET 9’s HttpMethod.Query and ASP.NET Core&#39;s ability to map custom HTTP methods using MapMethods, adopting the QUERY method is straightforward for APIs that need rich filtering capabilities.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5ebf1334fbb0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to upload files in chunks in the Azure blob storage account]]></title>
            <link>https://heyabhi.medium.com/how-to-upload-files-in-chunks-in-the-azure-blob-storage-account-73809c599dd2?source=rss-19972e292f2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/73809c599dd2</guid>
            <category><![CDATA[c-sharp-programming]]></category>
            <category><![CDATA[net-core]]></category>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[azure-blob]]></category>
            <dc:creator><![CDATA[Abhi Gupta]]></dc:creator>
            <pubDate>Tue, 25 Jun 2024 05:32:57 GMT</pubDate>
            <atom:updated>2024-06-25T05:32:57.990Z</atom:updated>
            <content:encoded><![CDATA[<p>Uploading files in chunks is a technique used to handle large file uploads by breaking the file into smaller, more manageable pieces (chunks) and sending each piece separately to the server. This method has several advantages, such as improving upload reliability and reducing the impact of network issues. Here’s how you can implement chunked file upload in a typical web application</p><p><strong>First, install Nuget library</strong></p><p>Azure.Storage.Blobs</p><p>Add the <a href="https://learn.microsoft.com/en-us/azure/storage/common/storage-configure-connection-string">connection string</a> and <a href="https://learn.microsoft.com/en-us/rest/api/storageservices/naming-and-referencing-containers--blobs--and-metadata">container name</a></p><pre>var StorageAccount = CloudStorageAccount.Parse(connectionString);<br>var BlobClient = StorageAccount.CreateCloudBlobClient();<br>var Container = BlobClient.GetContainerReference(&quot;ecomdata&quot;);<br> <br>var blob = Container.GetBlockBlobReference(blobrequest.Attachment.FileName);<br> <br>HashSet&lt;string&gt; blocklist = new HashSet&lt;string&gt;();<br> <br>var file = blobrequest.Attachment;<br>const int pageSizeInBytes = 10485760;<br>long prevLastByte = 0;<br>long bytesRemain = file.Length;<br>byte[] bytes;<br> <br>using (MemoryStream ms = new MemoryStream())<br>{<br>    var fileStream = file.OpenReadStream();<br>    await fileStream.CopyToAsync(ms);<br>    bytes = ms.ToArray();<br>}<br>do<br>{<br>    long bytesToCopy = Math.Min(bytesRemain, pageSizeInBytes);<br>    byte[] bytesToSend = new byte[bytesToCopy];<br> <br>    Array.Copy(bytes, prevLastByte, bytesToSend, 0, bytesToCopy);<br>    prevLastByte += bytesToCopy;<br>    bytesRemain -= bytesToCopy;<br> <br>    //Create blockId<br>    string blockId = Guid.NewGuid().ToString();<br>    string base64BlockId = Convert.ToBase64String(Encoding.UTF8.GetBytes(blockId));<br> <br>    await blob.PutBlockAsync(base64BlockId, new MemoryStream(bytesToSend, true), null);<br> <br>    blocklist.Add(base64BlockId);<br> <br>} while (bytesRemain &gt; 0);<br> <br>//post blocklist<br>await blob.PutBlockListAsync(blocklist);<br> <br>return &quot;done&quot;;</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=73809c599dd2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>