<![CDATA[Bhanu Prakash Korthiwada]]>https://bhanu.dev/https://bhanu.dev/favicon.pngBhanu Prakash Korthiwadahttps://bhanu.dev/Ghost 5.118Mon, 16 Mar 2026 22:45:36 GMT60<![CDATA[Accessing Web Root and Content Root Path's in ASP.NET Core]]>https://bhanu.dev/accessing-web-root-and-content-root-paths-in-asp-net-core/638a6c35ecef9b0157092d86Wed, 12 Jun 2019 11:04:01 GMTIn ASP.NET Core, the physical paths to both the web root and the content root directories can be retrieved by injecting and querying the IHostingEnvironment service:

using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;

namespace SampleDemo
{
    public class HomeController : Controller
    {
        private readonly IHostingEnvironment _hostingEnvironment;

        public HomeController(IHostingEnvironment hostingEnvironment)
        {
            _hostingEnvironment = hostingEnvironment;
        }

        public ActionResult Index()
        {
            string webRootPath = _hostingEnvironment.WebRootPath;
            string contentRootPath = _hostingEnvironment.ContentRootPath;

            return Content(webRootPath + "\n" + contentRootPath);
        }
    }
}

The web root is the root directory from which static content is served, while the content root is the application base path.

]]>
<![CDATA[Character Encoding Reference - URL and ASCII]]>https://bhanu.dev/html-encoding-characters-reference/638a6c35ecef9b0157092d85Fri, 07 Jun 2019 18:59:46 GMT

Character encoding is a method of converting bytes into characters. To validate or display an HTML document properly, a program must choose a proper character encoding.

The most common character set or character encoding in use on computers is ASCII − The American Standard Code for Information Interchange, and this is probably the most widely used character set for encoding text electronically.

ASCII encoding supports only the upper and lowercase Latin alphabet, the numbers 0-9, and some extra characters which make a total of 128 characters in all. You can have a look at complete set of Printable ASCII Characters

However, many languages use either accented Latin characters or completely different alphabets. ASCII does not address these characters; therefore, you need to learn about character encodings if you want to use any non-ASCII characters.

Similarly, URL encoding converts characters into a format that can be transmitted over the Internet.

Below are some of ASCII Character's and their respective URL Encoded values:

URL Encoding ASCII Character
%20 space
%21 !
%22
%23 #
%24 $
%25 %
%26 &
%27
%28 (
%29 )
%2A *
%2B +
%2C ,
%2D
%2E .
%2F /
%30 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5 å
%E6 æ
%E7 ç
%E8 è
%E9 é
%EA ê
%EB ë
%EC ì
%ED í
%EE î
%EF ï
%F0 ð
%F1 ñ
%F2 ò
%F3 ó
%F4 ô
%F5 õ
%F6 ö
%F7 ÷
%F8 ø
%F9 ù
%FA ú
%FB û
%FC ü
%FD ý
%FE þ
%FF ÿ
]]>
<![CDATA[WebAssembly - The New Web]]>https://bhanu.dev/webassembly/638a6c35ecef9b0157092d90Mon, 18 Feb 2019 23:58:00 GMT

WebAssembly (WASM) is the new web standard, it is a new type of code designed to be faster to parse than JavaScript and faster to execute. It is also designed to run alongside JavaScript, allowing both to work together.

WASM is supported in all modern browsers.

Why we should care about WebAssembly?

It provides a way to run code written in multiple languages on the web at near native speed.

using the WASM JavaScript APIs, we can load its modules into a JavaScript app and share functionality between them. This allows taking advantage of WebAssembly's performance and power and JavaScript's expressiveness and flexibility in the same apps.

Watch this video from Mozilla.

Is it a web standard?

WebAssembly is an emerging standard, with ongoing work on the specification. The browser vendors have reached consensus on the design of the initial wasm API and binary format, and it is being developed as a web standard with an active group via W3C WebAssembly Working Group with members from Mozilla, Microsoft, Google, and Apple.

How is this different from JavaScript?

The key words are low-level. It defines primitives including a range of types and operations on those types, literal forms for them, control-flow, calls, a heap, etc…

These are very simple primitives, No complicated object system, No built-in automatic garbage collector following you around and stopping you periodically while it cleans up your scraps.

An important fact to know is, WebAssembly is backward compatible. In fact, there is no versioning.

]]>
<![CDATA[UDP (User Datagram Protocol)]]>https://bhanu.dev/user-datagram-protocol/638a6c35ecef9b0157092d8eTue, 01 Jan 2019 23:53:00 GMTWhat is UDP?

UDP (User Datagram Protocol) is an alternative communications protocol to Transmission Control Protocol (TCP) used primarily for establishing low-latency and loss-tolerating connections between applications on the internet.

It uses a simple connectionless communication model with a minimum of protocol mechanism. UDP provides checksums for data integrity, and port numbers for addressing different functions at the source and destination of the datagram.

It is widely used for fire-and-forget protocols where packets are sent but their arrival or ordering is not guaranteed.

How UDP is different from TCP?

Both UDP and TCP run on top of the Internet Protocol (IP) and are sometimes referred to as UDP/IP or TCP/IP. But there are important differences between the two.

  1. Where UDP enables process-to-process communication, TCP supports host-to-host communication. TCP sends individual packets and is considered a reliable transport medium; UDP sends messages, called datagrams, and is considered a best-effort mode of communications.
  2. In addition, where TCP provides error and flow control, no such mechanisms are supported in UDP. UDP is considered a connectionless protocol because it doesn't require a virtual circuit to be established before any data transfer occurs.

Advantages of using UDP over TCP?

UDP just sends the packets, which means that it has much lower bandwidth overhead and latency. However with UDP, packets may take different paths between sender and receiver and, as a result, some packets may be lost or received out of order.

]]>
<![CDATA[HTTP/3 - The new web]]>https://bhanu.dev/http-3/638a6c35ecef9b0157092d8fTue, 13 Nov 2018 23:55:00 GMTWhat is QUIC?

QUIC (Quick UDP Internet Connections) is a new experimental protocol that promises to make web page connections faster, reliable and secure by default.

QUIC tries to make an HTTPS connection between a computer (phone) and server work reliably despite the poor conditions, it does this with a collection of technologies.

It is very similar to TCP+TLS+HTTP/2 implemented on UDP.


Expected Features of QUIC?

End-to-End encryption (All QUIC connections are fully encrypted)

Forward-Error Correction (FEC), this helps to reconstruct the message when it is garbled

Error-Correcting codes, this allow missing data to be reconstructed

Solving HTTP/2 HoL (head of line blocking) problem.

One of the slower parts of a standard HTTP/2 over TCP connection is the very beginning of http request. When the app or browser makes a connection there’s an initial handshake at the TCP level followed by a handshake to establish encryption. Over a high latency connection (like 2G/3G) which creates a noticeable delay. Since QUIC controls all aspects of the connect it merges together connection and encryption into a single handshake.


What's HTTP/3?

Now it's official that, HTTP/3 (earlier referred as HTTP-over-QUIC) is the coming new HTTP version that uses QUIC for transport!


Other Resources and Sources:

IETF Draft

QUIC Working Group Draft

QUIC Working Group Site

Cloudflare QUICing

]]>
<![CDATA[Progressive Web Apps]]>https://bhanu.dev/progressive-web-apps/638a6c35ecef9b0157092d8bWed, 21 Feb 2018 23:46:00 GMT

Progressive Web Apps (PWA) are the next big thing in web development as they bring mobile-app-like experiences to users without requiring them to install an app from the app store/ play store. It is now the new way to deliver amazing user experiences on the web.

What is it? and Why do we need it?

It is the same web but better. PWA's allow us to develop great websites that can behave like native apps.

Below are some advantages of it,

  • Load's instant, even in uncertain network conditions.
  • Responds quickly
  • Behaves like a native app with features like adding to Home Screen, push notifications, accessing to Camera, splash screen etc.,
  • Work's offline with Service Worker.
    many more...

We need it as PWA's will help for higher conversions and increases user engagement.

What are qualities of PWA?[1]

  • Progressive - Work for every user, regardless of browser choice because they’re built with progressive enhancement as a core tenet.
  • Responsive - Fit any form factor, desktop, mobile, tablet, or whatever is next.
  • Connectivity independent - Enhanced with service workers to work offline or on low-quality networks.
  • App-like - Use the app-shell model to offer app-style navigations and interactions.
  • Fresh - Always up-to-date thanks to the service worker update process.
  • Safe - Served via TLS to prevent snooping and make sure content hasn’t been tampered with.
  • Discoverable - Are identifiable as “applications” thanks to W3C manifests and service worker registration scope allowing search engines to find them.
  • Re-engageable - Make re-engagement easy through features like push notifications.
  • Installable - Allow users to “keep” apps they find most useful on their home screen without the hassle of an app store.
  • Linkable - Easily share via URL and not need complex installation.

Basic Progressive Web App Checklist

  • Site is served over HTTPS
  • Site is responsive across phone, tablet and desktop screen sizes
  • All app URLs load while offline
  • Metadata provided for Add to Home screen
  • First load fast even on 3G
  • Site works cross-browser
  • Each page has a URL
  • Page transitions don't feel like they block on the network

How to test Tools PWA?

Lighthouse Chrome Extension will provide analysis of PWA's

Here is the amazing list of PWA's available over web.

Cover Image[2]


Wiki ↩︎

Google ↩︎

]]>
<![CDATA[C# Multiple Return Values]]>https://bhanu.dev/c-sharp-multiple-return-values/638a6c35ecef9b0157092d8aThu, 01 Feb 2018 23:44:00 GMT

Many times we wanted to return multiple values, one solution is to create a model class and returning an instance of it.

Starting with C# 7, we can easily return multiple values using Tuples.

Tuples allow us to,

  • Create, access, and manipulate a data set
  • Return a data set from a method without using out parameter
  • Pass multiple values to a method through a single parameter

If applications target .NET Framework is 4.6.2 or lower then install NuGet package System.ValueTuple.

Use below command to install via Package Manager CLI.

 PM> Install-Package System.ValueTuple

Below is a simple example using Tuples:

 using System;

 class Program
 {
    static void Main()
    {
        Tuple<int, string, bool> tuple=new Tuple<int, string, bool>(2610, "Microsoft", true);
        // Using tuple properties.
        if (tuple.Item1 == 1)
        {
            Console.WriteLine(tuple.Item1);
        }
        if (tuple.Item2 == "dog")
        {
            Console.WriteLine(tuple.Item2);
        }
        if (tuple.Item3)
        {
            Console.WriteLine(tuple.Item3);
        }
    }
 }

There are various ways of declaring Tuples as below:

 // using keyword
 Tuple<int, string, bool> t1=new Tuple<int, string, bool>(2610, "Microsoft", true);

 // without Tuple keyword
 (int, string, bool) t1=(2610, "Microsoft", true);

 // using named variables
 (int uniqueId, string fromName, bool isValid) t1=(2610, "Microsoft", true);
]]>
<![CDATA[Sitecore CMS - Powershell Prompts]]>https://bhanu.dev/sitecore-prevent-powershell-prompts/638a6c35ecef9b0157092d8cMon, 15 Jan 2018 23:49:00 GMT

When working with Sitecore with Powershell Extensions, Powershell ISE prompts/alerts are distracting.

Below change in configuration will help to overcome the same.

Search for Cognifide.PowerShell.config in App_Config\Include folder in sitecore web root.

<tokens>
    <token name="Default" expiration="00:00:00" elevationAction="Allow"/>
    <token name="Console" expiration="00:05:00" elevationAction="Allow"/>
    <token name="ISE" expiration="00:05:00" elevationAction="Allow"/>
    <token name="ItemSave" expiration="00:05:00" elevationAction="Allow"/>
</tokens>

Update the configuration as required, above example is suggested only for Local environment only.

elevationAction can be any value as below:

  • Block - always block action
  • Password - Ask for Password to elevate session
  • Allow - Always allow to elevate session without asking

expiration is TimeSpan serialized for how long session should stay elevated.

]]>