<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Janki Mehta</title>
    <description>The latest articles on Forem by Janki Mehta (@me_janki).</description>
    <link>https://forem.com/me_janki</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1113065%2Fd1b2d763-e5dc-47af-a115-b611b178e10a.jpg</url>
      <title>Forem: Janki Mehta</title>
      <link>https://forem.com/me_janki</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/me_janki"/>
    <language>en</language>
    <item>
      <title>Why .NET is Poised for Massive Growth in 2024</title>
      <dc:creator>Janki Mehta</dc:creator>
      <pubDate>Thu, 25 Jan 2024 04:42:27 +0000</pubDate>
      <link>https://forem.com/me_janki/why-net-is-poised-for-massive-growth-in-2024-27i4</link>
      <guid>https://forem.com/me_janki/why-net-is-poised-for-massive-growth-in-2024-27i4</guid>
      <description>&lt;p&gt;The .NET development framework has been around for over 20 years now, first released by Microsoft in 2002. Over this time, it has evolved significantly from early versions like .NET 1.0 and .NET 2.0 to the latest iterations of .NET 6 and beyond. As the framework has matured and added new capabilities, more developers and businesses have adopted it for web, desktop, mobile, and cloud applications.&lt;/p&gt;

&lt;p&gt;Looking ahead to 2024, &lt;strong&gt;&lt;a href="https://positiwise.com/blog/the-increasing-demand-for-net-development"&gt;Increasing demand for .NET development&lt;/a&gt;&lt;/strong&gt; skills from both developers and employers is projected to continue increasing for several key reasons:&lt;/p&gt;

&lt;h2&gt;
  
  
  Cross-Platform Support
&lt;/h2&gt;

&lt;p&gt;One of the biggest changes for .NET in recent years has been the shift to fully support cross-platform development. In the past, .NET was seen as tightly coupled to Windows. However, with .NET Core in 2016 and .NET 5 released in 2020, developers can now build .NET applications targeting Windows, Linux, macOS, iOS, and Android from the same codebase.&lt;/p&gt;

&lt;p&gt;This cross-platform capability has opened up .NET to a much wider audience of developers who may have previously avoided it due to platform lock-in concerns. It also allows businesses using a variety of operating systems in their infrastructure to leverage .NET developers more easily. As more organizations adopt hybrid and multi-cloud environments, the cross-platform nature of modern .NET will drive greater demand.&lt;/p&gt;

&lt;h2&gt;
  
  
  Language &amp;amp; Framework Advancements
&lt;/h2&gt;

&lt;p&gt;Microsoft has continued advancing the C# programming language as well as the core .NET framework. New features in C# like nullable reference types, async streams, and top-level statements make the language even more powerful and enjoyable to use.&lt;/p&gt;

&lt;p&gt;The .NET framework itself has also gained capabilities like Hot Reload for faster development workflows, cloud-native support through ASP.NET Core, and better integration with Kubernetes, Docker, and containers in general. These ongoing improvements help ensure .NET remains highly productive and relevant for building modern applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  Enterprise Application Demand
&lt;/h2&gt;

&lt;p&gt;While startups and smaller companies continue fueling demand, bigger enterprises rely on .NET heavily as well. According to a 2017 survey, over 80% of Fortune 500 companies use .NET for at least some applications. Many core business systems at large banks, retailers, manufacturers, and other organizations were built on .NET decades ago and require ongoing support and enhancements.&lt;/p&gt;

&lt;p&gt;As digital transformation initiatives accelerate across all industries, these organizations will drive extensive demand for .NET skills to modernize, migrate, and expand their mission-critical applications. Budgets for application development, maintenance, and DevOps are growing, and .NET has an established place within many major companies.&lt;/p&gt;

&lt;h2&gt;
  
  
  Rising Demand for Full-Stack Skills
&lt;/h2&gt;

&lt;p&gt;Full-stack development combining both front-end and back-end skills is increasingly desirable for building complete applications. Companies want developers who can work with the entire tech stack rather than specialists in just one area.&lt;/p&gt;

&lt;p&gt;With the introduction of Blazor in .NET 5, developers can now create rich web UIs using C#/Razor components that run in the browser with WebAssembly instead of traditional JavaScript frameworks. Blazor has the potential to reshape full-stack development by unifying client and server using a single language.&lt;/p&gt;

&lt;p&gt;As the Blazor ecosystem matures, demand for .NET developers with complementary skills like C#, ASP.NET Core, and Blazor will grow substantially. Those with full-stack .NET backgrounds will be highly sought after.&lt;/p&gt;

&lt;h2&gt;
  
  
  Employment &amp;amp; Salary Outlook
&lt;/h2&gt;

&lt;p&gt;The combination of increased adoption, ongoing enhancements, and rising demand across industries means the job prospects and earning potential for .NET developers remains strong.&lt;/p&gt;

&lt;p&gt;According to data from Dice and other job sites, the number of .NET-related postings on Indeed increased by over 150% between 2017-2021. Average base salaries for intermediate and senior .NET positions typically range from $80,000 to $130,000 per year in the US. Many locations also have lower costs of living than tech hubs.&lt;/p&gt;

&lt;p&gt;Long-term forecasts also indicate robust growth ahead. The Bureau of Labor Statistics projects a 9% increase in jobs for software developers through 2030, much faster than average. For experienced .NET professionals, job security and opportunities for career advancement or job-hopping should remain plentiful in 2024.&lt;/p&gt;

&lt;h2&gt;
  
  
  In summary,
&lt;/h2&gt;

&lt;p&gt;with the platform's cross-platform flexibility, advancing language and features, entrenchment in major enterprises, rise of full-stack opportunities, and abundant job prospects, the overall demand profile of .NET development looks exceedingly bright as we head into 2024 and beyond. Strong professionals in the .NET ecosystem can feel confident about the continuing need and usage of their skills.&lt;/p&gt;

</description>
      <category>aspnet</category>
      <category>dotnet</category>
      <category>growth</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Tips to Create Your First ASP.NET Core Application</title>
      <dc:creator>Janki Mehta</dc:creator>
      <pubDate>Wed, 27 Dec 2023 11:40:41 +0000</pubDate>
      <link>https://forem.com/me_janki/tips-to-create-your-first-aspnet-core-application-24gb</link>
      <guid>https://forem.com/me_janki/tips-to-create-your-first-aspnet-core-application-24gb</guid>
      <description>&lt;p&gt;ASP.NET Core is one of the most popular open-source web frameworks for building modern web applications and services on the .NET platform. Its modular and lightweight design, cross-platform support, high performance, and rich ecosystem make it a great choice for building web APIs, websites, mobile backends, and more.&lt;/p&gt;

&lt;p&gt;In this beginner-friendly tutorial, we'll build a simple "Hello World" ASP.NET Core web application from scratch. We'll walk through:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Setting up the development environment with the .NET Core SDK&lt;/li&gt;
&lt;li&gt;Creating a new ASP.NET Core project&lt;/li&gt;
&lt;li&gt;Running the app locally&lt;/li&gt;
&lt;li&gt;Adding a basic web API endpoint&lt;/li&gt;
&lt;li&gt;Testing the output&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By the end, you'll have a good foundational understanding of how ASP.NET Core works and be ready to build more complex real-world applications. The goal is to get you up and running with core concepts so you can start leveraging the power and capabilities of ASP.NET Core for your own projects.&lt;/p&gt;

&lt;p&gt;Let's get started!&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;Before we start, make sure you have the following installed:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;.NET Core SDK 3.1 or later&lt;/li&gt;
&lt;li&gt;A text editor or IDE like Visual Studio, Visual Studio Code etc.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Create the Application
&lt;/h3&gt;

&lt;p&gt;Let's start by creating a new ASP.NET Core web application.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Open a command prompt or terminal and navigate to the directory where you want to create the app.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Type the following command:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dotnet new web -o MyFirstApp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It will create a new ASP.NET Core web project in a folder called MyFirstApp.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Navigate into this new folder:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd MyFirstApp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The project contains a Program.cs file with the entry point code and a Startup.cs file for configuring services and the request pipeline.&lt;/p&gt;

&lt;h3&gt;
  
  
  Run the Application
&lt;/h3&gt;

&lt;p&gt;We can now run the web app locally to see the default page.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;From the command prompt in the application folder, run:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dotnet run
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open a web browser and go to &lt;a href="https://localhost:5001"&gt;https://localhost:5001&lt;/a&gt;. You should see the default ASP.NET Core web page.&lt;/p&gt;

&lt;h3&gt;
  
  
  Add Some Code
&lt;/h3&gt;

&lt;p&gt;Let's add a simple API endpoint to return "Hello World".&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open the Startup.cs file.&lt;/li&gt;
&lt;li&gt;Add the following code inside the Configure method:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; 
&lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WriteAsync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Hello World!"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Run dotnet run again and refresh the browser. You should now see "Hello World!"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And that's it! We now have a simple ASP.NET Core web application up and running.&lt;/p&gt;

&lt;h3&gt;
  
  
  Next Steps
&lt;/h3&gt;

&lt;p&gt;This was just a basic example to get started. From here, you can start adding controllers, views, models etc., to build a real web application.&lt;/p&gt;

&lt;p&gt;The official ASP.NET Core docs are a great next resource to learn more about ASP.NET Core and its features.&lt;/p&gt;

&lt;p&gt;We walked through setting up the development environment, creating a new project, running the application locally, adding a basic API endpoint, and testing the output. This should give &lt;a href="https://positiwise.com/hire/hire-dot-net-core-developers"&gt;ASP.NET Core developers&lt;/a&gt; a good overview of the basic structure and workflow of ASP.NET Core applications. Of course, this was just a simple example - ASP.NET Core is capable of powering robust, scalable enterprise web applications and services. The official documentation contains many more in-depth guides on leveraging the full capabilities of ASP.NET Core.&lt;/p&gt;

&lt;p&gt;I hope this tutorial served as an easy way for ASP.NET Core developers to get started building web applications on the .NET platform. Let me know if you have any other questions!&lt;/p&gt;

</description>
      <category>aspnet</category>
      <category>aspdotnet</category>
      <category>aspnetc</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Collecting Metrics in ASP.NET Core Applications</title>
      <dc:creator>Janki Mehta</dc:creator>
      <pubDate>Wed, 20 Dec 2023 13:30:52 +0000</pubDate>
      <link>https://forem.com/me_janki/collecting-metrics-in-aspnet-core-applications-49cm</link>
      <guid>https://forem.com/me_janki/collecting-metrics-in-aspnet-core-applications-49cm</guid>
      <description>&lt;p&gt;Monitoring and metrics are crucial for any production application. It provides visibility into how your application is performing, helps with debugging issues, and enables data-driven decisions for improving performance and scalability. This post will explore common ways to collect and expose metrics from ASP.NET Core applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  What are Metrics?
&lt;/h2&gt;

&lt;p&gt;Metrics represent quantifiable measurements about an application or system at a given time or over time. Common metrics include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Request Count: Number of requests received by the application&lt;/li&gt;
&lt;li&gt;Request Duration: How long do requests take on average to respond&lt;/li&gt;
&lt;li&gt;Memory Usage: Amount of memory the application is consuming&lt;/li&gt;
&lt;li&gt;CPU Usage: Percentage of CPU the application is using&lt;/li&gt;
&lt;li&gt;Exception Count: Number of exceptions thrown by the application&lt;/li&gt;
&lt;li&gt;Response Status Codes: Breakdown of response status codes (200, 404, 500 etc.)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A metric by itself doesn't tell much but provides insightful trends over time. Metrics are key to monitoring, alerting, performance baselining, and application capacity planning.&lt;/p&gt;

&lt;h2&gt;
  
  
  Built-in ASP.NET Core Metrics
&lt;/h2&gt;

&lt;p&gt;ASP.NET Core comes with built-in support for collecting some basic out-of-the-box metrics. These metrics are exposed through the HttpMetrics Middleware registered by default in CreateWebHostBuilder().&lt;/p&gt;

&lt;p&gt;Some of the key built-in metrics are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Request Count&lt;/li&gt;
&lt;li&gt;Response Count (broken down by status code)&lt;/li&gt;
&lt;li&gt;Total Request Duration&lt;/li&gt;
&lt;li&gt;Request Duration (broken down by status code)
The middleware writes these metrics to the HTTP response headers on every request. It makes them easily accessible without additional infrastructure.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example, you could view the metrics using Postman or curl to inspect the X-aspnet-Version X-AspNet-Variables-RequestCount response headers.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight apache"&gt;&lt;code&gt;X-AspNet-Version: 5.0.0-rc.2.20475.5
X-AspNet-Variables-RequestCount: 6
X-AspNet-Variables-RequestDuration-Sum: 3.424999999402344
&lt;span class="err"&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;While convenient, exposing metrics only via headers has limitations. Headers do not support deeper historical aggregation or flexible export options required for robust monitoring. For that, additional libraries are needed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Metric Libraries
&lt;/h2&gt;

&lt;p&gt;Several open-source libraries integrate nicely with ASP.NET Core to provide more advanced metric collection capabilities:&lt;/p&gt;

&lt;h3&gt;
  
  
  Prometheus
&lt;/h3&gt;

&lt;p&gt;Prometheus is one of the most popular open-source monitoring systems. At configurable intervals, it supports scraping metrics via HTTP from targets like ASP.NET Core apps.&lt;br&gt;
The Prometheus.AspNetCore.Metrics package allows exporting the built-in ASP.NET Core metrics in the Prometheus exposition format. It also adds additional .NET/ASP.NET-specific metrics like GC stats, Requests Inflight, memory usage, etc.&lt;br&gt;
The metrics endpoint is added at /metrics Prometheus can scrape to collect data. This data can then be visualized, alerted on, etc, using the Prometheus ecosystem of tools like Grafana.&lt;/p&gt;
&lt;h3&gt;
  
  
  StatsD
&lt;/h3&gt;

&lt;p&gt;StatsD is a protocol and server for aggregating and summarizing metrics. It supports sending metrics over UDP.&lt;br&gt;
The MicroSteam.StatsD library provides StatsD client functionality and integration for ASP.NET Core. It allows easy incrementing counters, timing metrics, etc, from the application code and pipeline.&lt;br&gt;
These metrics can then be sent to a StatsD server and visualized using tools like Grafana. StatsD also supports integration with other backends like InfluxDB, Prometheus, etc.&lt;/p&gt;
&lt;h3&gt;
  
  
  Application Insights
&lt;/h3&gt;

&lt;p&gt;Application Insights is a comprehensive Application Performance Management (APM) service by Microsoft for web apps hosted in any environment, including on-premises.&lt;br&gt;
The Microsoft.ApplicationInsights.AspNetCore package collects the built-in ASP.NET metrics and additional diagnostics and availability data and sends it to the Application Insights resource.&lt;br&gt;
It provides out-of-the-box dashboards and search and powerful analytics capabilities on the portal. Application Insights is ideal for applications hosted on Azure.&lt;/p&gt;
&lt;h3&gt;
  
  
  App Metrics
&lt;/h3&gt;

&lt;p&gt;App Metrics is a cross-platform .NET library for instrumenting applications and collecting metrics. It supports exporting metrics to various backends like Prometheus, InfluxDB, ElasticSearch, etc.&lt;br&gt;
The App.Metrics.AspNetCore package provides middleware to collect ASP.NET Core metrics like request counters, durations, etc and integrates with the App Metrics instrumentation API.&lt;br&gt;
It is lightweight, has minimal overhead, and provides a consistent metrics API across platforms and languages. App Metrics works well even for non-Azure-hosted applications.&lt;/p&gt;
&lt;h2&gt;
  
  
  Choosing the Right Library
&lt;/h2&gt;

&lt;p&gt;Here are some factors to consider when choosing a metrics library:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Deployment Platform:&lt;/strong&gt; Application Insights is ideal for apps hosted on Azure. Prometheus for Kubernetes/Docker environments. StatsD for generic backend agnostic collection.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Visualization Needs:&lt;/strong&gt; If requiring out-of-the-box dashboards, Application Insights excels. Prometheus/Grafana or custom solutions on top of StatsD/App Metrics works.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Backend Preferences:&lt;/strong&gt; Prometheus for Prometheus and Elasticsearch. StatsD for Sumo Logic, Datadog etc. Application Insights for its backend.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Portability:&lt;/strong&gt; App Metrics work across platforms. Prometheus is only for HTTP targets. Application Insights tied to MS ecosystem.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Overhead:&lt;/strong&gt; Application Insights and Prometheus have more startup overhead than App Metrics or StatsD.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Feature Set:&lt;/strong&gt; Application Insights is most fully featured for APM. Prometheus for observability. StatsD/App Metrics for lightweight collection.
Hence, Application Insights is easy to use for Azure-hosted apps. Prometheus for complex on-prem/containerized setups. StatsD/App Metrics for low overhead collection with flexible exporters.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Instrumenting Code
&lt;/h2&gt;

&lt;p&gt;Collecting application-level metrics requires instrumenting the code in strategic places. Here are some examples:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Track Request Timing&lt;/strong&gt;&lt;br&gt;
Use the IActionFilter to track request timing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;RequestTimingFilter&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;IActionFilter&lt;/span&gt; 
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;OnActionExecuting&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ActionExecutingContext&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;HttpContext&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Items&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"Timer"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Stopwatch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;StartNew&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;OnActionExecuted&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ActionExecutedContext&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;timer&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;HttpContext&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Items&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"Timer"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;Stopwatch&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;timer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Stop&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="c1"&gt;// Record request duration&lt;/span&gt;
    &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;appMetrics&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;HttpContext&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;RequestServices&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;GetRequiredService&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;IAppMetrics&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;();&lt;/span&gt; 
    &lt;span class="n"&gt;appMetrics&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Measure&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;RequestDuration&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Measure&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;timer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Elapsed&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Track Dependency Calls
&lt;/h2&gt;

&lt;p&gt;Track timing of external dependency calls:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="n"&gt;Task&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;IActionResult&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;Index&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; 
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;timer&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Stopwatch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;StartNew&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="c1"&gt;// Call dependency   &lt;/span&gt;
  &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;_client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GetUsers&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;  
  &lt;span class="n"&gt;timer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Stop&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="c1"&gt;// Record duration&lt;/span&gt;
  &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;appMetrics&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;HttpContext&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;RequestServices&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;GetRequiredService&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;IAppMetrics&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;();&lt;/span&gt;
  &lt;span class="n"&gt;appMetrics&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Measure&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Dependency&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Database"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;Measure&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;timer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Elapsed&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;View&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Track Exceptions
&lt;/h2&gt;

&lt;p&gt;Count exceptions occurring in specific code blocks:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;try&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Method that could throw&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Exception&lt;/span&gt; &lt;span class="n"&gt;ex&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;appInsights&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;HttpContext&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;RequestServices&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;GetRequiredService&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Microsoft&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ApplicationInsights&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;TelemetryClient&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;();&lt;/span&gt;
  &lt;span class="n"&gt;appInsights&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;TrackException&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ex&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Instrumenting at strategic places like this provides actionable insights without many code changes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Exposing Metrics Endpoint
&lt;/h2&gt;

&lt;p&gt;Most metric libraries provide a way to expose metrics through an endpoint that can be scraped. For example:&lt;/p&gt;

&lt;h3&gt;
  
  
  Prometheus
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;Configure&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IApplicationBuilder&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;IWebHostEnvironment&lt;/span&gt; &lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;UseMetricServer&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  StatsD
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;UseMetricsEndpoint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/stats"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;metrics&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;metrics&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Statsd&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Exposes metrics at /stats&lt;/p&gt;

&lt;h2&gt;
  
  
  App Metrics
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;UseMetricApi&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Exposes metrics via Prometheus, InfluxDB endpoints&lt;/p&gt;

&lt;p&gt;Scraping this endpoint periodically provides a consistent way to collect metrics in production. Services like Prometheus are ideal for automated scraping.&lt;/p&gt;

&lt;h2&gt;
  
  
  Alerting on Metrics
&lt;/h2&gt;

&lt;p&gt;While metrics provide visibility, it's also important to configure alerts to be notified of issues. Metric libraries typically integrate with alerting systems:&lt;/p&gt;

&lt;h2&gt;
  
  
  Prometheus Alertmanager
&lt;/h2&gt;

&lt;p&gt;Prometheus has an integrated Alertmanager for grouping, routing, and sending alerts. Rules can be configured using the Prometheus Query Language to fire alerts based on metric thresholds.&lt;br&gt;
For example, to alert if requests are taking more than 1 second on average:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;alert: SlowRequests
expr: avg(aspnet_request_duration_seconds_bucket{le="1"}) &amp;lt; 0.9
for: 5m

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Alerts can be sent via email, PagerDuty, Slack, etc. This provides automated notifications for performance issues.&lt;/p&gt;

&lt;h2&gt;
  
  
  Application Insights Alerts
&lt;/h2&gt;

&lt;p&gt;In Application Insights, metric alerts can be configured on dashboards, workbooks, or directly in the portal.&lt;br&gt;
Custom metric queries allow setting alerts on application-specific metrics, too. Notifications go to email, SMS, ARM templates, and more.&lt;/p&gt;

&lt;h3&gt;
  
  
  App Metrics Alerts
&lt;/h3&gt;

&lt;p&gt;App Metrics exposes Prometheus-compatible metrics so that the Alertmanager can be used. Its plugin model also supports sending alerts to external systems like Slack.&lt;/p&gt;

&lt;h3&gt;
  
  
  Logging and Tracing
&lt;/h3&gt;

&lt;p&gt;While metrics provide a high-level overview of an application, diagnosing issues requires correlating them with logs and traces:&lt;/p&gt;

&lt;p&gt;ASP.NET Core Logging&lt;br&gt;
The logging APIs allow capturing logs across the application. Libraries like Serilog and NLog provide rich log formatting and routing.&lt;/p&gt;

&lt;h3&gt;
  
  
  Application Insights Tracing
&lt;/h3&gt;

&lt;p&gt;Application Insights application tracing correlates logs, exceptions, and external dependencies with requests' client-side performance.&lt;/p&gt;

&lt;h3&gt;
  
  
  Distributed Tracing with Prometheus
&lt;/h3&gt;

&lt;p&gt;Prometheus can be combined with a distributed tracing system like Jaeger to trace requests across services. Libraries like OpenTelemetry make it easy to generate and propagate distributed traces.&lt;br&gt;
Bringing logs, traces, and metrics together provides deep insights needed to debug performance bottlenecks and failures across complex applications and microservices.&lt;/p&gt;

&lt;h3&gt;
  
  
  Performance Benchmarking
&lt;/h3&gt;

&lt;p&gt;To establish performance benchmarks, tools like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Gatling:&lt;/strong&gt; Load test ASP.NET Core APIs and analyze results.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;K6:&lt;/strong&gt; Open source load testing tool with JavaScript scripting.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Neoload:&lt;/strong&gt; Commercial load testing tool.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Vegeta:&lt;/strong&gt; CLI tool for hammering URLs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Running performance tests against baseline configurations helps determine scalability bottlenecks and capacity planning. Metrics from tests can be exported to the same backend as production for apples-to-apples comparison.&lt;/p&gt;

&lt;p&gt;Summary&lt;br&gt;
Setting up a comprehensive monitoring and metrics platform is crucial for the production &lt;a href="https://positiwise.com/blog/net-core-best-practices"&gt;ASP.NET Core apps&lt;/a&gt;. The built-in middleware provides a good starting point. Libraries like Prometheus, Application Insights, StatsD, and App Metrics integrate to collect deeper metrics seamlessly. Instrumentation at the right places provides actionable insights. Alerts detect issues and bring log traces together, providing full diagnostics. Performance tests help establish benchmarks for scaling. With the right approach, actionable insights can be gained without much operational overhead.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Node.js vs NestJS – Understanding their Technical Difference</title>
      <dc:creator>Janki Mehta</dc:creator>
      <pubDate>Mon, 11 Dec 2023 13:23:15 +0000</pubDate>
      <link>https://forem.com/me_janki/nodejs-and-nestjs-understanding-their-technical-difference-4224</link>
      <guid>https://forem.com/me_janki/nodejs-and-nestjs-understanding-their-technical-difference-4224</guid>
      <description>&lt;p&gt;Node.js and NestJS are both popular JavaScript platforms for building efficient, scalable server-side applications. Node.js is a runtime that allows developers to use JavaScript on the server, while NestJS is a framework that builds on top of Node.js, providing more structure and scalability out-of-the-box.&lt;/p&gt;

&lt;p&gt;Both have their pros and cons and are better suited for certain types of applications. At a high level, Node.js offers more flexibility and works well for simple APIs and microservices, while NestJS shines when building complex, enterprise-grade applications thanks to its robust feature set.&lt;/p&gt;

&lt;p&gt;This article will provide an overview of both platforms, compare their architectures and performance, discuss factors to consider when choosing one or the other, and make some recommendations on when NestJS is the better option over plain Node.js or vice versa.&lt;/p&gt;

&lt;h2&gt;
  
  
  Node.js Overview
&lt;/h2&gt;

&lt;p&gt;Node.js exploded in popularity upon its release in 2009, thanks to its ability to execute JavaScript code outside of the browser, its efficient use of asynchronous/non-blocking I/O, and its support for real-time applications.&lt;/p&gt;

&lt;p&gt;Instead of waiting for requests and responses to complete before moving to another task, Node.js uses an event loop that allows it to handle high volumes of concurrent requests without incurring the overhead of managing threads. This makes Node.js well-suited for data-intensive real-time applications like chat rooms and streaming platforms.&lt;/p&gt;

&lt;h3&gt;
  
  
  Benefits of Node.js
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Large ecosystem of open-source libraries and tools&lt;/li&gt;
&lt;li&gt;Great for prototyping and iterating quickly&lt;/li&gt;
&lt;li&gt;Lean and fast compared to other server-side frameworks&lt;/li&gt;
&lt;li&gt;JavaScript skills transfer nicely from front-end&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Downsides of Node.js
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Limited structure and architecture can be chaotic&lt;/li&gt;
&lt;li&gt;Heavy use of callbacks can lead to callback hell&lt;/li&gt;
&lt;li&gt;Not great for complex or enterprise-grade applications&lt;/li&gt;
&lt;li&gt;Must assemble most features yourself&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Hence, Node.js is a great choice for lightweight web applications, simple APIs and microservices, anything requiring real-time data, and MVPs or prototypes where flexibility and speed of iteration is key.&lt;/p&gt;

&lt;h2&gt;
  
  
  NestJS Overview
&lt;/h2&gt;

&lt;p&gt;Released in 2016, NestJS provides an out-of-the-box application architecture for building scalable Node.js servers using JavaScript/TypeScript. It officially bills itself as "a progressive Node.js framework for building enterprise-grade efficient, reliable, and scalable server-side applications."&lt;/p&gt;

&lt;h3&gt;
  
  
  Capabilities of NestJS
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Built-in support for a modular organization using controllers, providers, modules, and more&lt;/li&gt;
&lt;li&gt;Sophisticated dependency injection system&lt;/li&gt;
&lt;li&gt;A CLI tool for the generation of boilerplate code&lt;/li&gt;
&lt;li&gt;Easy to implement middleware and guards thanks to built-in decorators&lt;/li&gt;
&lt;li&gt;Exception filters for centralized error handling&lt;/li&gt;
&lt;li&gt;Framework for unit and e2e testing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By providing structure, NestJS makes larger applications much easier to maintain and expand. The learning curve is a bit steeper than Node, but they’ve done a great job making documentation and training resources readily available.&lt;/p&gt;

&lt;p&gt;Downsides compared to Node.js are mainly increased complexity and tighter coupling to the NestJS platform. The framework handles so much automatically that migrating away later requires significant refactoring.&lt;/p&gt;

&lt;h3&gt;
  
  
  Use cases where NestJS shines over bare Node.js
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Highly scalable applications needing easy maintenance&lt;/li&gt;
&lt;li&gt;Anything with intricate business logic or complex flows&lt;/li&gt;
&lt;li&gt;Teams with less experienced Node developers&lt;/li&gt;
&lt;li&gt;When unit testing and sound architecture are key&lt;/li&gt;
&lt;li&gt;Processing lots of data across distributed systems&lt;/li&gt;
&lt;li&gt;CRUD APIs requiring validation, authorization, logging automatically&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Hence, while Node.js gives you a canvas and brush to create your own masterpiece, NestJS provides a rich set of paint-by-numbers features so engineering teams can build robust applications faster.&lt;/p&gt;

&lt;h2&gt;
  
  
  Differences between NodeJS and NestJS
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Comparing Architectures
&lt;/h3&gt;

&lt;p&gt;There are quite a few differences between Node.js and NestJS under the hood, but we’ll focus on some key ones around file structure and request handling flow.&lt;/p&gt;

&lt;h3&gt;
  
  
  File Structure
&lt;/h3&gt;

&lt;p&gt;A typical Node.js application might just throw all server logic into a single index.js file, or separate concerns across a simple controllers/, services/, models/ type folder structure. NestJS enforces further modularization using:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Controllers: Handle incoming requests and return responses&lt;/li&gt;
&lt;li&gt;Providers: Services that contain core business logic, interacting with databases, making API calls, etc.&lt;/li&gt;
&lt;li&gt;Modules: Self-contained units of business capabilities that group related controllers/providers&lt;/li&gt;
&lt;li&gt;Middleware: Functions executed during the request handling pipeline&lt;/li&gt;
&lt;li&gt;Guards: Functions that control access to specific endpoints&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Request Handling Flow
&lt;/h3&gt;

&lt;p&gt;When a request comes into a Node.js app, you manually take that request and route it across any number of modules, controllers, and services you’ve wired up. Any middleware needs to be explicitly inserted as well.&lt;/p&gt;

&lt;p&gt;NestJS sets things up differently using dependency injection and a built-in IoC container. A request first hits any global middleware then flows through a pipeline roughly like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Request -&amp;gt; Guard -&amp;gt; Interceptor -&amp;gt; 
    -&amp;gt; Controller -&amp;gt; Service -&amp;gt; Repository

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It provides standardization and consistency across implementations.&lt;/p&gt;

&lt;h3&gt;
  
  
  Performance
&lt;/h3&gt;

&lt;p&gt;As far as runtime performance and benchmarks, NestJS introduces minimal overhead over Node, usually less than 1%. For example, a common benchmark serving JSON shows Node.js at ~31k requests/second and NestJS at ~30k.&lt;/p&gt;

&lt;p&gt;So, in terms of pure speed, the two are very comparable. Where Nest really accelerates development velocity is through its robust feature set and architectural conventions.&lt;/p&gt;

&lt;p&gt;Considerations in Deciding Which one to choose. NodeJS or NestJS&lt;br&gt;
When embarking on a new project, how do you decide whether to use NestJS versus plain Node.js? Here are some factors to weigh.&lt;/p&gt;

&lt;h3&gt;
  
  
  Team &amp;amp; Project
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Team experience level with Node/Nest and typescript&lt;/li&gt;
&lt;li&gt;App complexity and size&lt;/li&gt;
&lt;li&gt;Desired development velocity&lt;/li&gt;
&lt;li&gt;Availability of quality Node.js dev resources&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Business Factors
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Target users and expected traffic&lt;/li&gt;
&lt;li&gt;Pace of enhancement/feature requests&lt;/li&gt;
&lt;li&gt;Application availability/stability needs&lt;/li&gt;
&lt;li&gt;Compliance requirements&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Technical Factors
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Integration needs with external services/databases&lt;/li&gt;
&lt;li&gt;Real-time requirements like chat or streaming&lt;/li&gt;
&lt;li&gt;Need for scalability/maintainability&lt;/li&gt;
&lt;li&gt;Testing needs and CI/CD processes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If your team is familiar with Node and TypeScript, starting with NestJS as the baseline for almost any material project is likely to pay off exponentially in long-term velocity and stability.&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary and Recommendations
&lt;/h2&gt;

&lt;p&gt;To summarize the key differences:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Node.js offers ultimate flexibility while NestJS provides structure and conventions&lt;/li&gt;
&lt;li&gt;Node good for simple real-time services and micro front-ends.&lt;/li&gt;
&lt;li&gt;Nest enables robust complex applications, with integrated best practices&lt;/li&gt;
&lt;li&gt;Nest has steeper initial learning curve
Here are some quick rules of thumb on when to default to each:&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Node.js
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Simple CRUD APIs and microservices&lt;/li&gt;
&lt;li&gt;Prototyping ideas where speed matters most&lt;/li&gt;
&lt;li&gt;Front-end Node microservices&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Public-facing real-time features&lt;br&gt;
NestJS&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Nearly everything else!&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Internal enterprise applications&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Heavy business logic&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Cross functional/database integrations&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Legacy codebases benefitting modernization&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Prioritizing maintainability&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The overhead NestJS introduces gets paid back over the long haul via accelerated development velocity, clean architecture, and easy maintainability. Unless building a public API to support millions of users per day, teams are usually better served starting with NestJS from the get-go.&lt;/p&gt;

</description>
      <category>node</category>
      <category>nestjs</category>
      <category>javascript</category>
      <category>jscript</category>
    </item>
    <item>
      <title>Style a DataTable in React Native Paper</title>
      <dc:creator>Janki Mehta</dc:creator>
      <pubDate>Wed, 06 Dec 2023 07:03:33 +0000</pubDate>
      <link>https://forem.com/me_janki/style-a-datatable-in-react-native-paper-5c1i</link>
      <guid>https://forem.com/me_janki/style-a-datatable-in-react-native-paper-5c1i</guid>
      <description>&lt;p&gt;The DataTable component in React Native Paper provides a clean and customizable way to display tabular data on mobile. However, out of the box, it comes with default styling that may not always fit with the design and styling of your application. Fortunately, the DataTable is fully customizable through React Native styling, which allows you to precisely control elements like colors, spacing, borders, and more to match your branding and user interface guidelines.&lt;/p&gt;

&lt;p&gt;Styling the DataTable correctly is important to provide a consistent and polished experience for users when viewing and interacting with lists of data. This article will demonstrate some common techniques for styling the key elements of the DataTable, such as the header, rows, and individual cell content, to achieve a custom look and feel.&lt;/p&gt;

&lt;h2&gt;
  
  
  Here's the Tips to Style a DataTable in React Native Paper
&lt;/h2&gt;

&lt;p&gt;import React Native Paper and the DataTable component:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;DataTable&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react-native-paper&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Define some sample data as an array:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;bd7acbea-c1b1-46c2-aed5-3ad53abb28ba&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;firstName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;First Name 1&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;lastName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Last Name 1&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;3ac68afc-c605-48d3-a4f8-fbd91aa97f63&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;firstName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;First Name 2&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;lastName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Last Name 2&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="c1"&gt;// etc&lt;/span&gt;
&lt;span class="p"&gt;];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Render the DataTable passing in the data:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;DataTable&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;DataTable&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Header&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;DataTable&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Title&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Id&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;DataTable&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Title&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;DataTable&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Title&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;First Name&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;DataTable&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Title&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; 
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;DataTable&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Title&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Last Name&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;DataTable&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Title&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;DataTable&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Header&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;

  &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;DataTable&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Row&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    // map over data
  &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;DataTable&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Row&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;DataTable&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To style it, wrap it in a StyleSheet:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;StyleSheet&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;DataTable&lt;/span&gt; 
    &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;borderColor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;blue&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; 
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    //...
  &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;DataTable&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;StyleSheet&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can then style individual components like Header, Title, Row etc:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;DataTable&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Title&lt;/span&gt; 
  &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;green&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  First Name
&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;DataTable&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Title&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Some other useful styles include controlling padding, borders, text colors, sizes etc.&lt;/p&gt;

&lt;p&gt;The DataTable component provides a solid foundation for displaying tabular data on mobile while also giving developers full control over styling through React Native. With some basic use of StyleSheet definitions and component-specific styles, you can customize elements like colors, sizing, spacing, and more to match any design. Taking the time to style the DataTable carefully ensures a polished user experience when viewing lists of information.&lt;br&gt;
Whether you need to adjust colors or achieve a completely bespoke design simply, the styling capabilities allow you to integrate tabular content into your unique UI perfectly. For professional &lt;a href="https://positiwise.com/technologies/reactjs-development"&gt;React JS Development&lt;/a&gt; teams and independent developers alike, leveraging these styling techniques provides an effective way to build out feature-rich, customizable data browsing experiences with React Native Paper.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Create SOAP Services Using ASP.NET Core</title>
      <dc:creator>Janki Mehta</dc:creator>
      <pubDate>Fri, 01 Dec 2023 12:55:08 +0000</pubDate>
      <link>https://forem.com/me_janki/create-soap-services-using-aspnet-core-2i6f</link>
      <guid>https://forem.com/me_janki/create-soap-services-using-aspnet-core-2i6f</guid>
      <description>&lt;p&gt;SOAP (Simple Object Access Protocol) is a messaging protocol that allows programs built with different languages and on different platforms to communicate using XML. SOAP services provide a way to expose backend functionality over the web using the SOAP messaging framework.&lt;/p&gt;

&lt;p&gt;In this blog post, we will see how to create and consume SOAP web services in ASP.NET Core. We will learn how to:&lt;/p&gt;

&lt;h2&gt;
  
  
  Enable SOAP services support in ASP.NET Core
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Create a SOAP web service&lt;/li&gt;
&lt;li&gt;Add SOAP endpoints&lt;/li&gt;
&lt;li&gt;Secure SOAP endpoints&lt;/li&gt;
&lt;li&gt;Host and test SOAP services&lt;/li&gt;
&lt;li&gt;Consume SOAP services in client applications&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Enabling SOAP Services in ASP.NET Core
&lt;/h2&gt;

&lt;p&gt;Unlike ASP.NET 4.x that has built-in support for SOAP-based web services through ASMX, ASP.NET Core does not include SOAP services capability out of the box.&lt;/p&gt;

&lt;p&gt;We need to take help of a third-party library called System.ServiceModel.Primitives to build SOAP-based services in ASP.NET Core.&lt;/p&gt;

&lt;p&gt;To add SOAP services support, first install the NuGet package:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="n"&gt;Install&lt;/span&gt;&lt;span class="p"&gt;-&lt;/span&gt;&lt;span class="n"&gt;Package&lt;/span&gt; &lt;span class="n"&gt;System&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ServiceModel&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Primitives&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This package contains the necessary types and interfaces to expose and consume SOAP services. The next sections show how to build on top of this to create SOAP endpoints.&lt;/p&gt;

&lt;p&gt;Creating a SOAP Web Service&lt;br&gt;
Let's create a simple SOAP web service with one operation to get customer details by ID.&lt;/p&gt;

&lt;p&gt;First, create an interface representing the service contract:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;interface&lt;/span&gt; &lt;span class="nc"&gt;ICustomerService&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;Customer&lt;/span&gt; &lt;span class="nf"&gt;GetCustomer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Customer&lt;/span&gt; 
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;Id&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;Name&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, implement this interface:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;CustomerService&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;ICustomerService&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="n"&gt;Customer&lt;/span&gt; &lt;span class="nf"&gt;GetCustomer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Logic to fetch data from database and return Customer&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This simple service is now ready to be exposed over SOAP.&lt;/p&gt;

&lt;h2&gt;
  
  
  Exposing SOAP Endpoints
&lt;/h2&gt;

&lt;p&gt;ASP.NET Core does not include SOAP endpoint support out of the box. So we need to configure that ourselves.&lt;/p&gt;

&lt;p&gt;Install the NuGet package - Microsoft.AspNetCore.WebApi.WebHost&lt;/p&gt;

&lt;p&gt;This will allow hosting web APIs on top of HTTP servers like IIS or IIS Express.&lt;/p&gt;

&lt;p&gt;In Startup.cs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;ConfigureServices&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IServiceCollection&lt;/span&gt; &lt;span class="n"&gt;services&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;services&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;AddWebApi&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

    &lt;span class="n"&gt;services&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;AddScoped&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;ICustomerService&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;CustomerService&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;();&lt;/span&gt; 

    &lt;span class="n"&gt;services&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;AddSoapCore&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;Configure&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IApplicationBuilder&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;UseSoapEndpoint&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;ICustomerService&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;(&lt;/span&gt;&lt;span class="s"&gt;"/CustomerService.asmx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;BasicHttpBinding&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;SoapSerializer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DataContractSerializer&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The AddSoapCore method comes from SoapCore library that does the heavy-lifting of mapping SOAP messages over HTTP.&lt;/p&gt;

&lt;p&gt;And UseSoapEndpoint maps the specified interface to the SOAP endpoint, with binding and serialization set up.&lt;/p&gt;

&lt;p&gt;We can now access the SOAP service using HTTP requests like any REST API. The next section shows how to test this.&lt;/p&gt;

&lt;p&gt;Testing the SOAP API&lt;br&gt;
Let's test our SOAP API using SoapUI or Postman.&lt;/p&gt;

&lt;p&gt;A sample request XML looks like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;soapenv:Envelope&lt;/span&gt; &lt;span class="na"&gt;xmlns:soapenv=&lt;/span&gt;&lt;span class="s"&gt;"http://schemas.xmlsoap.org/soap/envelope/"&lt;/span&gt; &lt;span class="na"&gt;xmlns:tem=&lt;/span&gt;&lt;span class="s"&gt;"http://tempuri.org/"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
   &lt;span class="nt"&gt;&amp;lt;soapenv:Header/&amp;gt;&lt;/span&gt;
   &lt;span class="nt"&gt;&amp;lt;soapenv:Body&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;tem:GetCustomer&amp;gt;&lt;/span&gt;
         &lt;span class="nt"&gt;&amp;lt;tem:id&amp;gt;&lt;/span&gt;1&lt;span class="nt"&gt;&amp;lt;/tem:id&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;/tem:GetCustomer&amp;gt;&lt;/span&gt;
   &lt;span class="nt"&gt;&amp;lt;/soapenv:Body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/soapenv:Envelope&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And response like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;s:Envelope&lt;/span&gt; &lt;span class="na"&gt;xmlns:s=&lt;/span&gt;&lt;span class="s"&gt;"http://schemas.xmlsoap.org/soap/envelope/"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;s:Body&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;GetCustomerResponse&lt;/span&gt; &lt;span class="na"&gt;xmlns=&lt;/span&gt;&lt;span class="s"&gt;"http://tempuri.org/"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;Customer&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;Id&amp;gt;&lt;/span&gt;1&lt;span class="nt"&gt;&amp;lt;/Id&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;Name&amp;gt;&lt;/span&gt;John&lt;span class="nt"&gt;&amp;lt;/Name&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;/Customer&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/GetCustomerResponse&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/s:Body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/s:Envelope&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can send requests and view responses either in SoapUI or using Postman. This confirms our service is working as expected.&lt;/p&gt;

&lt;h2&gt;
  
  
  Securing SOAP Services
&lt;/h2&gt;

&lt;p&gt;Since SOAP services expose backend application logic, it is important to secure access to them. Some ways to secure SOAP services include:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Transport-Level Security using HTTPS&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Require SSL and allow requests only using HTTPS protocol.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Message-Level Security&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Use WS-Security to encrypt SOAP requests and responses.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Authentication and Authorization&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Validate sender identity using security tokens or API keys before processing requests.&lt;/p&gt;

&lt;p&gt;This ensures that only authorized clients can access the SOAP API.&lt;/p&gt;

&lt;p&gt;Here is an example to secure the service using API key authentication:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Validate API Key existence&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(!&lt;/span&gt;&lt;span class="n"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Headers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Contains&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"X-API-Key"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; 
    &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;Exception&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Unauthorized"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Check if API Key is valid&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(!&lt;/span&gt;&lt;span class="nf"&gt;IsAPIKeyValid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Headers&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"X-API-Key"&lt;/span&gt;&lt;span class="p"&gt;]))&lt;/span&gt; 
    &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;Exception&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Forbidden"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Allow request&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can implement other authentication mechanisms like OAuth as well.&lt;/p&gt;

&lt;h2&gt;
  
  
  Hosting ASP.NET Core SOAP Services
&lt;/h2&gt;

&lt;p&gt;To host the SOAP web service, configure the ASP.NET Core app to use the IIS/IIS Express hosting model:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="n"&gt;IWebHostBuilder&lt;/span&gt; &lt;span class="nf"&gt;CreateWebHostBuilder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt;
    &lt;span class="n"&gt;WebHost&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;CreateDefaultBuilder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;UseStartup&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Startup&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;()&lt;/span&gt;
        &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;UseIIS&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Alternatively, we can self-host the service using Kestrel.&lt;/p&gt;

&lt;p&gt;For production use, hosting behind IIS with transport security is recommended.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Consuming SOAP Web Services&lt;/strong&gt;&lt;br&gt;
To consume ASP.NET Core SOAP web services from a .NET client:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add service reference to client project&lt;/li&gt;
&lt;li&gt;Generate proxy client code&lt;/li&gt;
&lt;li&gt;Create client instance and invoke service operations
For example:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// 1. Add service reference &lt;/span&gt;

&lt;span class="c1"&gt;// 2. Generate proxy&lt;/span&gt;
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;CustomerServiceClient&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;  

&lt;span class="c1"&gt;// 3. Call operation&lt;/span&gt;
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;customer&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GetCustomer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The service reference handles all serialization/deserialization and communication with the SOAP endpoint.&lt;/p&gt;

&lt;p&gt;For Java or other language clients, we can consume the ASP.NET Core SOAP service by generating client code using the wsdl file.&lt;/p&gt;

&lt;h2&gt;
  
  
  Last Words
&lt;/h2&gt;

&lt;p&gt;In this post, we learned how to build and expose SOAP web services in ASP.NET Core using the SoapCore library. Some of the key things we covered:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Adding NuGet packages for SOAP support&lt;/li&gt;
&lt;li&gt;Creating service interfaces and implementation&lt;/li&gt;
&lt;li&gt;Configuring SOAP endpoint routing&lt;/li&gt;
&lt;li&gt;Testing SOAP API using SoapUI/Postman&lt;/li&gt;
&lt;li&gt;Securing services with authentication and HTTPS&lt;/li&gt;
&lt;li&gt;Hosting SOAP services in IIS&lt;/li&gt;
&lt;li&gt;Consuming from .NET clients&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;SOAP services allow exposing backend application logic in a standardized way. Integrating them securely into modern web apps allows reusing existing systems.&lt;/p&gt;

&lt;p&gt;Hope this gives you a good overview of building SOAP-based services in ASP.NET Core web applications!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Source: &lt;a href="https://positiwise.com/blog/how-to-create-soap-services-using-asp-net-core"&gt;How to Create SOAP Services Using ASP.NET Core?&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>soap</category>
      <category>aspnet</category>
      <category>aspdotnet</category>
      <category>csharp</category>
    </item>
    <item>
      <title>React Native vs Swift: Which is Best for Your Mobile App Development?</title>
      <dc:creator>Janki Mehta</dc:creator>
      <pubDate>Wed, 29 Nov 2023 11:23:06 +0000</pubDate>
      <link>https://forem.com/me_janki/react-native-vs-swift-which-is-best-for-your-mobile-app-development-3hdb</link>
      <guid>https://forem.com/me_janki/react-native-vs-swift-which-is-best-for-your-mobile-app-development-3hdb</guid>
      <description>&lt;p&gt;As a mobile app developer, you have many options for which platform and programming language to choose when building a new app. Two popular choices are React Native and Swift. Both allow you to create fully functional mobile apps for iOS and Android. But each has its own strengths and weaknesses. In this blog post, we will compare React Native vs Swift across several key factors to help you determine which is the best technology for your needs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Overview
&lt;/h2&gt;

&lt;p&gt;React Native is a JavaScript library open-sourced by Facebook in 2015 that allows you to build mobile apps using &lt;a href="https://positiwise.com/technologies/reactjs-development" rel="noopener noreferrer"&gt;React&lt;/a&gt; and JavaScript. With React Native, developers can build once and deploy to both iOS and Android with shared code without writing platform-specific code.&lt;/p&gt;

&lt;p&gt;Swift is a general-purpose, multi-paradigm, compiled programming language developed by Apple and first released in 2014. Swift is designed to work with Apple's Cocoa and Cocoa Touch frameworks and works seamlessly with iOS, macOS, watchOS, and tvOS. With Swift, you can build fully native iOS and macOS apps.&lt;/p&gt;

&lt;h2&gt;
  
  
  Comparison Table: React Native vs Swift
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyx2z0isawrw0ozqytswq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyx2z0isawrw0ozqytswq.png" alt="React Native vs Swift"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Swift vs React Native – Difference on Various Factors
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Development Experience and Tools
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The main development tools for React Native are React tools, VS Code, WebStorm, and other IDEs that support React/JavaScript development. Developers code in JavaScript using React components and APIs.&lt;/li&gt;
&lt;li&gt;The primary development tool for Swift is Xcode, Apple's integrated development environment (IDE). Xcode includes tools like storyboards for building UI, the Swift compiler, and debugger. Code is written in Swift and seamlessly integrated with native iOS libraries and APIs.&lt;/li&gt;
&lt;li&gt;The learning curve for React Native is generally steeper than Swift since it requires knowledge of JavaScript, React, and some mobile development concepts. Swift is easier for iOS developers since it's similar to Objective-C.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Performance
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;React Native apps are reported to have near-native performance. The React Native bridge converts JavaScript calls to native platform calls, allowing components to render at 60 FPS. However, there may be some additional overhead compared to fully native apps.&lt;/li&gt;
&lt;li&gt;Swift delivers true native performance since code runs directly on the device like a standard iOS app. Animation and interaction will be indistinguishable from other apps on the store since everything renders using the same UIKit framework.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Cross-Platform Development
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The big advantage of React Native is cross-platform capabilities. With largely shared code, you can develop once and release to both iOS and Android platforms, cutting development time versus writing fully native code.&lt;/li&gt;
&lt;li&gt;Swift is a native language, so code only runs on Apple platforms like iOS, macOS, watchOS, or tvOS. If targeting other platforms like Android, you would need to rewrite code or use a cross-platform framework like React Native or Flutter.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Integration with Native Features
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;While React Native exposes many common mobile features through wrappers and APIs, it's always an extra abstraction layer away from the true native platforms. For cutting-edge features or deeper platform integration, you may hit limits.&lt;/li&gt;
&lt;li&gt;In Swift, everything integrates seamlessly with native frameworks right out of the box. You get direct access to the full power of devices like the camera, sensors, filesystem, etc, without additional layers.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Support and Community
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;React Native and Swift have very large, vibrant developer communities that provide help, tutorials, and open-source libraries. Facebook is actively developing React Native, with many companies adopting it.&lt;/li&gt;
&lt;li&gt;Apple has a huge ecosystem backing Swift as the primary language for their platforms. Resources and help will be easily available if issues arise. Swift also has a bright future as Apple continually invests in the language.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  FAQs
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Q1. Which is easier to learn - React Native or Swift?
&lt;/h3&gt;

&lt;p&gt;Swift would generally be easier for new developers since the syntax is clearer and integrates seamlessly with Apple's platforms. React Native introduces additional concepts like JavaScript React, which requires more background learning.&lt;/p&gt;

&lt;h3&gt;
  
  
  Q2. Can I create both iOS and Android apps with Swift?
&lt;/h3&gt;

&lt;p&gt;Swift is only for building native iOS, watchOS, macOS, and tvOS applications. To target Android, you would need a cross-platform framework like React Native or Flutter.&lt;/p&gt;

&lt;h3&gt;
  
  
  Q3. How is React Native animation and interaction compared to native?
&lt;/h3&gt;

&lt;p&gt;Animation and interaction with React Native are close to native but not the same since it renders using the native platform's APIs rather than directly using platform UI frameworks. Advanced animations may require additional work.&lt;/p&gt;

&lt;h3&gt;
  
  
  Q4. Is React Native suitable for complex apps with intensive graphics?
&lt;/h3&gt;

&lt;p&gt;React Native can handle complex apps, including 3D games and AR/VR experiences. But for the most intensive graphical needs, a fully native solution may have an advantage in terms of raw performance.&lt;/p&gt;

&lt;h3&gt;
  
  
  Q5. How do updates work in React Native vs native apps?
&lt;/h3&gt;

&lt;p&gt;With React Native, you can ship code and API updates through JavaScript bundles, avoiding the app store approval process. Native app updates must go through app stores for installation on users' devices.&lt;/p&gt;

&lt;h3&gt;
  
  
  Q6. What are some limitations of React Native?
&lt;/h3&gt;

&lt;p&gt;Potential limitations include performance overhead, limited ability for truly native look/feel, bugs from SDK mismatches, third-party library compatibility, and debugging challenges.&lt;/p&gt;

&lt;h3&gt;
  
  
  Q7. How do I connect React Native to backend servers?
&lt;/h3&gt;

&lt;p&gt;Common ways include utilizing fetch API for HTTP requests, WebSocket connections for real-time features, or a library like React Native Networking for a higher-level abstraction.&lt;/p&gt;

&lt;h3&gt;
  
  
  Q8. Do I need separate iOS and Android codebases in React Native?
&lt;/h3&gt;

&lt;p&gt;No, with React Native, you develop using a single JavaScript codebase that can be compiled for both iOS and Android. Only a small amount of native platform-specific code is needed for each platform.&lt;/p&gt;

&lt;h3&gt;
  
  
  Q9. Can I use existing Swift/Objective-C code in React Native?
&lt;/h3&gt;

&lt;p&gt;Yes, React Native allows the inclusion of existing Objective-C/Swift code and libraries within a project through native modules that encapsulate platform-specific functionality in a reusable way.&lt;/p&gt;

&lt;h3&gt;
  
  
  Q10. Which is better for large, complex enterprise apps - React Native or Swift?
&lt;/h3&gt;

&lt;p&gt;Both can work well for large, complex apps. React Native enables easier cross-platform development, while Swift delivers best-in-class native performance. For an established iOS-first enterprise, Swift may integrate more seamlessly into existing codebases and processes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Thought on React Native vs Swift
&lt;/h2&gt;

&lt;p&gt;Both React Native and Swift are outstanding options for building high-quality mobile apps. React Native allows development for multiple platforms like iOS and Android using shared JavaScript code. At the same time, Swift is the optimal choice for fully utilizing the power of iOS, macOS, and other Apple platforms.&lt;br&gt;
Ultimately, the right choice comes down to your specific needs - platforms supported, performance requirements, development experience preferences, and existing codebase or tools. Consider prototyping with both to see which suits your use case better before committing long-term. With the large communities behind each, you can create amazing mobile experiences with either technology.&lt;/p&gt;

</description>
      <category>react</category>
      <category>reactnative</category>
      <category>swift</category>
      <category>javascript</category>
    </item>
    <item>
      <title>How to Create PDF Documents in ASP.NET Core</title>
      <dc:creator>Janki Mehta</dc:creator>
      <pubDate>Fri, 24 Nov 2023 05:50:34 +0000</pubDate>
      <link>https://forem.com/me_janki/how-to-create-pdf-documents-in-aspnet-core-1b37</link>
      <guid>https://forem.com/me_janki/how-to-create-pdf-documents-in-aspnet-core-1b37</guid>
      <description>&lt;p&gt;PDF generation is a common requirement for many web applications. ASP.NET Core provides several options for generating PDF documents directly from .NET code. In this article, we'll explore some of the main approaches for creating PDFs in ASP.NET Core apps.&lt;/p&gt;

&lt;p&gt;We'll cover:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Using built-in PDF generation support&lt;/li&gt;
&lt;li&gt;Third-party libraries like iTextSharp and PDFSharp&lt;/li&gt;
&lt;li&gt;Generating PDFs from HTML/CSS using libraries like PDFKit and Puppeteer Sharp&lt;/li&gt;
&lt;li&gt;Rendering to PDF on the server vs the client&lt;/li&gt;
&lt;li&gt;Sample code for a basic PDF generation scenario&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By the end, you should have a good understanding of the different techniques available and how to get started generating PDFs from your ASP.NET Core applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  Built-in PDF Support
&lt;/h2&gt;

&lt;p&gt;The .NET Framework and .NET Core provide some basic built-in functionality for generating PDF documents programmatically without a third-party dependency.&lt;/p&gt;

&lt;p&gt;The System.Drawing namespace includes classes like PdfDocument and XGraphics that allow creating PDF files pixel-by-pixel. You can draw text, images, vectors, and more onto a PdfPage and save the result as a PDF file.&lt;/p&gt;

&lt;p&gt;An example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Create a new PdfDocument object&lt;/span&gt;
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;pdfDoc&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;PdfDocument&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; 

&lt;span class="c1"&gt;// Add a page&lt;/span&gt;
&lt;span class="n"&gt;pdfDoc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;AddPage&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;// Get an XGraphics object for drawing&lt;/span&gt;
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;gfx&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;XGraphics&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;FromPdfPage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pdfDoc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Pages&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;

&lt;span class="c1"&gt;// Draw text  &lt;/span&gt;
&lt;span class="n"&gt;gfx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;DrawString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Hello World!"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;font&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;XBrushes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Black&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Save the document and dispose it&lt;/span&gt;
&lt;span class="n"&gt;pdfDoc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Save&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"HelloWorld.pdf"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;pdfDoc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Dispose&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This provides a basic building block but has limitations. Text/layout is rendered pixel-by-pixel so it may not scale or print well. There is also no support for things like vector graphics, tables, hyperlinks etc.&lt;/p&gt;

&lt;p&gt;For richer PDF generation capabilities, third-party libraries are recommended.&lt;/p&gt;

&lt;h2&gt;
  
  
  Third-Party Libraries
&lt;/h2&gt;

&lt;p&gt;There are a number of high-quality third-party .NET libraries for generating sophisticated PDF documents from code:&lt;/p&gt;

&lt;h4&gt;
  
  
  iTextSharp
&lt;/h4&gt;

&lt;p&gt;iTextSharp is one of the most full-featured and mature open source .NET PDF libraries available. It allows building PDF documents from scratch using elements like paragraphs, tables, images etc. Layout is handled separately from rendering so documents scale well.&lt;/p&gt;

&lt;p&gt;An example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Create a document and open it  &lt;/span&gt;
&lt;span class="n"&gt;Document&lt;/span&gt; &lt;span class="n"&gt;pdfDoc&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;Document&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;PageSize&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;A4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;25&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;25&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;25&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;25&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;PdfWriter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GetInstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pdfDoc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ms&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;pdfDoc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Open&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; 

&lt;span class="c1"&gt;// Add content&lt;/span&gt;
&lt;span class="n"&gt;Paragraph&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;Paragraph&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Hello World!"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;pdfDoc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Close the document&lt;/span&gt;
&lt;span class="n"&gt;pdfDoc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Close&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  PDFSharp
&lt;/h4&gt;

&lt;p&gt;PDFSharp is another popular open source .NET library. It uses a page-oriented model and the drawing API is similar to GDI+. This makes it easy to render to PDF from existing GDI/GDI+ code.&lt;/p&gt;

&lt;p&gt;An example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Create a new PDF document&lt;/span&gt;
&lt;span class="n"&gt;PdfDocument&lt;/span&gt; &lt;span class="n"&gt;pdfDoc&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;PdfDocument&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;// Add a page&lt;/span&gt;
&lt;span class="n"&gt;PdfPage&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pdfDoc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;AddPage&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; 

&lt;span class="c1"&gt;// Get drawing object and render&lt;/span&gt;
&lt;span class="n"&gt;XGraphics&lt;/span&gt; &lt;span class="n"&gt;gfx&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;XGraphics&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;FromPdfPage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;gfx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;DrawString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Hello World!"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;font&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;XBrushes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Black&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Save the document&lt;/span&gt;
&lt;span class="n"&gt;pdfDoc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Save&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"HelloWorld.pdf"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  wkhtmltopdf
&lt;/h4&gt;

&lt;p&gt;wkhtmltopdf is a command line tool that renders HTML/CSS to PDF using the Webkit rendering engine. It can be used from .NET code by launching the process. This allows generating PDFs from dynamic HTML/CSS content.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Render HTML to a stream&lt;/span&gt;
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;proc&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;Process&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="n"&gt;StartInfo&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;ProcessStartInfo&lt;/span&gt;
   &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;FileName&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"wkhtmltopdf.exe"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
      &lt;span class="n"&gt;Arguments&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;$"-q - -"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="n"&gt;RedirectStandardInput&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
      &lt;span class="n"&gt;RedirectStandardOutput&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;true&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="n"&gt;proc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Start&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="n"&gt;proc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;StandardInput&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;proc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;StandardInput&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Close&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="n"&gt;proc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WaitForExit&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;// Output stream contains PDF&lt;/span&gt;
&lt;span class="n"&gt;pdf&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;proc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;StandardOutput&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;BaseStream&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These are some of the most popular .NET PDF libraries. Each has its strengths - choose based on your specific requirements.&lt;/p&gt;

&lt;h2&gt;
  
  
  Generating from HTML/CSS
&lt;/h2&gt;

&lt;p&gt;Another common approach is to generate PDF from HTML/CSS content since it's easy to work with. There are a few options for doing this in .NET:&lt;/p&gt;

&lt;h4&gt;
  
  
  PDFKit
&lt;/h4&gt;

&lt;p&gt;PDFKit is a .NET library that uses the HTML rendering engine WebKit to convert HTML + CSS to PDF documents.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Create a PDFKit document&lt;/span&gt;
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;pdfDoc&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;PdfDocument&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; 

&lt;span class="c1"&gt;// Add a page and render HTML&lt;/span&gt;
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pdfDoc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;AddPage&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Render&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;markup&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 

&lt;span class="c1"&gt;// Save PDF&lt;/span&gt;
&lt;span class="n"&gt;pdfDoc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Save&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"HelloWorld.pdf"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Puppeteer Sharp
&lt;/h4&gt;

&lt;p&gt;Puppeteer Sharp is a .NET port of the Puppeteer Node.js library for controlling headless Chrome. It can render HTML to PDF using the Chromium rendering engine.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;browser&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;Puppeteer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;LaunchAsync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;browser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;NewPageAsync&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GoToAsync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;PdfAsync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;output&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;browser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;CloseAsync&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  HTML to PDF Converter
&lt;/h2&gt;

&lt;p&gt;This library uses the HTML Rendering engine in .NET to convert HTML markup to PDF.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;html&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;@"&amp;lt;h1&amp;gt;Hello World!&amp;lt;/h1&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;pdf&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;HtmlToPdfConverter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ConvertHtmlToPdf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="n"&gt;File&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WriteAllBytes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"HelloWorld.pdf"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Hence, these options allow rendering dynamic HTML/CSS content to high-fidelity PDF documents from .NET.&lt;/p&gt;

&lt;h3&gt;
  
  
  Server vs Client Rendering
&lt;/h3&gt;

&lt;p&gt;There are two main approaches for generating PDFs - on the server or client-side:&lt;/p&gt;

&lt;h4&gt;
  
  
  Server-Side
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Generate PDF directly from server code using a library&lt;/li&gt;
&lt;li&gt;Respond with generated PDF file&lt;/li&gt;
&lt;li&gt;Server handles all processing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Pros:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Faster response for users&lt;/li&gt;
&lt;li&gt;No client-side dependencies&lt;/li&gt;
&lt;li&gt;Easier to implement&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Cons:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;More load on server&lt;/li&gt;
&lt;li&gt;No interactivity&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Client-Side
&lt;/h4&gt;

&lt;p&gt;Return HTML/data needed to render PDF&lt;br&gt;
Use client-side library like jsPDF to generate PDF in browser&lt;br&gt;
User downloads/gets link to generated file&lt;br&gt;
&lt;strong&gt;Pros:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reduces server load&lt;/li&gt;
&lt;li&gt;Allows for richer interactivity&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Cons:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Slower initial response&lt;/li&gt;
&lt;li&gt;Requires client-side code/libraries
So for simple static PDFs, server-side is better. For interactive/dynamic generation, consider a client-side approach.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example Project&lt;/strong&gt;&lt;br&gt;
To put this into practice, here is a simple ASP.NET Core MVC sample project that generates a PDF on the server:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Controller action&lt;/span&gt;
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="n"&gt;IActionResult&lt;/span&gt; &lt;span class="nf"&gt;GeneratePdf&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; 
&lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="c1"&gt;// Create document object&lt;/span&gt;
   &lt;span class="n"&gt;Document&lt;/span&gt; &lt;span class="n"&gt;pdfDoc&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;Document&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;PageSize&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;A4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;25&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;25&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;25&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;25&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

   &lt;span class="c1"&gt;// Write content&lt;/span&gt;
   &lt;span class="nf"&gt;WriteParagraph&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pdfDoc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Hello World!"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

   &lt;span class="c1"&gt;// Write to memory stream&lt;/span&gt;
   &lt;span class="n"&gt;MemoryStream&lt;/span&gt; &lt;span class="n"&gt;ms&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;MemoryStream&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
   &lt;span class="n"&gt;PdfWriter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GetInstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pdfDoc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ms&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

   &lt;span class="n"&gt;pdfDoc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Close&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

   &lt;span class="c1"&gt;// Return generated PDF&lt;/span&gt;
   &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;File&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ms&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ToArray&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="s"&gt;"application/pdf"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Helper to add paragraph&lt;/span&gt;
&lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;WriteParagraph&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Document&lt;/span&gt; &lt;span class="n"&gt;pdfDoc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="n"&gt;Paragraph&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;Paragraph&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
   &lt;span class="n"&gt;pdfDoc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;This demonstrates:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Creating a PDF using iTextSharp&lt;/li&gt;
&lt;li&gt;Adding simple content&lt;/li&gt;
&lt;li&gt;Writing PDF to a stream&lt;/li&gt;
&lt;li&gt;Returning PDF file result&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With this approach, the server generates the PDF on request without any client-side processing required.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;In this article, we covered several techniques for programmatically generating PDF documents from ASP.NET Core applications. Whether you need a simple solution or full featured generation, .NET provides many high quality options.&lt;/p&gt;

&lt;p&gt;The key aspects discussed were:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Leveraging built-in .NET PDF support&lt;/li&gt;
&lt;li&gt;Popular third-party libraries like iTextSharp and PDFSharp&lt;/li&gt;
&lt;li&gt;Generating PDFs from HTML/CSS content&lt;/li&gt;
&lt;li&gt;Rendering on server vs client&lt;/li&gt;
&lt;li&gt;Sample code for a basic PDF generation scenario&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With the right approach, ASP.NET Core makes developing PDF generation capabilities straightforward. Choose the technique that best fits your specific application requirements.&lt;/p&gt;

</description>
      <category>aspnet</category>
      <category>aspdotnet</category>
      <category>asp</category>
      <category>pdf</category>
    </item>
    <item>
      <title>How to Assess C# Skills and Experience in Interviews</title>
      <dc:creator>Janki Mehta</dc:creator>
      <pubDate>Mon, 20 Nov 2023 12:49:48 +0000</pubDate>
      <link>https://forem.com/me_janki/how-to-assess-c-skills-and-experience-in-interviews-2ak6</link>
      <guid>https://forem.com/me_janki/how-to-assess-c-skills-and-experience-in-interviews-2ak6</guid>
      <description>&lt;p&gt;As a hiring manager looking to fill C# developer roles, you want to make sure you properly assess candidates' skills and experience with the language and related technologies. Vetting C# capabilities thoroughly during the interview process is crucial for identifying the right people to add to your team.&lt;/p&gt;

&lt;p&gt;In this blog post, we’ll explore tips and techniques for evaluating C# developers' abilities through questions, code samples, and practical exercises. Read on to learn how to dig into candidates' knowledge across a range of areas like .NET Framework, object-oriented principles, web development, and cloud platforms. With the right interview approach, you can gain invaluable insights into applicants' real-world expertise.&lt;/p&gt;

&lt;h2&gt;
  
  
  Review Their Resume and Background
&lt;/h2&gt;

&lt;p&gt;The interview begins long before the actual meeting itself. Closely examining a candidate's resume, cover letter, and other background materials provides early clues about their experience with C# and related technologies.&lt;/p&gt;

&lt;p&gt;Here are key things to look for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Previous Job Titles and Descriptions:&lt;/strong&gt; Look for specific roles like C# Developer, .NET Developer, and Web Applications Developer. Also, note how long they spent in each relevant position. Longer tenures suggest stronger abilities.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Projects and Achievements:&lt;/strong&gt; Scan for examples of major projects or apps they built with C#. What problems did they solve, and what specific tasks did they handle? How large were the codebases?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Open-source Contributions:&lt;/strong&gt; Involvement with open-source C#/NET projects, like contributing to .NET Core, indicates a passion for the ecosystem. Even minor bug fixes to GitHub repositories can demonstrate real coding abilities.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Overall Years of Experience:&lt;/strong&gt; While not always a perfect proxy, more years working professionally with C# generally equates to deeper knowledge and exposure to more aspects of the language and framework.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Any other background information, like speaking at a .NET user group meeting or taking a Udemy course on ASP.NET Core, also helps paint a picture of their overall skills.&lt;/p&gt;

&lt;p&gt;By cataloging candidate’s backgrounds ahead of time, you’ll have a framework to dig deeper into their experiences during the interviews.&lt;/p&gt;

&lt;p&gt;Ask About Their Education and Training&lt;br&gt;
Formal education and training provide a structured way for developers to build C# skills. Be sure to discuss these topics:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Related Major/Degree:&lt;/strong&gt; Did they study computer science, software engineering, or another related field? Relevant university degrees suggest basic coding skills and theoretical knowledge.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;C# or .NET Focused Courses:&lt;/strong&gt; Many schools offer specific classes on building applications and web services with C#. These courses dive deep into language features and framework capabilities. Ask about any noteworthy projects or apps created for class assignments.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Certifications:&lt;/strong&gt; C# and .NET certifications demonstrate commitment to mastering the technology. Microsoft, in particular, offers various credential programs related to its development stack, like the Microsoft Certified Solutions Developer certification. There are also 3rd party certification bodies with C#-focused programs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Online Classes:&lt;/strong&gt; With the wealth of e-learning content available today, many developers supplement their practical experience with online classes. Platforms like Pluralsight, Udemy, and LinkedIn Learning all offer robust C# content. See if they’ve taken relevant courses covering ASP.NET, Unity, or other topics.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bootcamps/Intensive Training:&lt;/strong&gt; Some candidates from non-traditional backgrounds attend intensive coding boot camps focused on C# and .NET skills. These accelerated 3-12 week programs aim to equip new developers with practical abilities through hands-on training. Ask about their boot camp curriculums and post-graduation projects.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Conference/Meetup Attendance:&lt;/strong&gt; Active membership in the C# community, through attending conferences like Microsoft Ignite or Meetup groups, demonstrates engagement. Speaking/presenting at these events takes it a step further.
The combination of formal coursework, certifications, online training, and community participation all help build a well-rounded skillset.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Discuss Their Hands-On C# Coding Skills
&lt;/h2&gt;

&lt;p&gt;While resumes and education provide background context, you need to directly assess candidates’ hands-on C# skills during the interview. Through coding challenges, take-home projects, and questions on language internals, you can get a sense of how they apply their knowledge.&lt;br&gt;
Here are effective ways to evaluate their proficiency:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Give Coding Challenges Focused on C#/NET Concepts:&lt;/strong&gt; Have them write LINQ queries, build objects that implement interfaces, work with asynchronous code, or demonstrate other language-specific capabilities with short coding prompts. This shows if they can quickly translate concepts into real C# code.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Provide Realistic Coding Problems Resembling On-the-job Tasks:&lt;/strong&gt; Avoid puzzles and theory-heavy algorithm questions. Instead give prompts like building part of a web API, a simple IoT application, or code to parse/process a sample data file. The goal is to simulate actual problems developers face day-to-day.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ask About Debugging Techniques:&lt;/strong&gt; Every developer spends significant time fixing bugs. See how they walk through diagnosing different issues like infinite loops, race conditions between threads, unhandled exceptions, etc. This demonstrates how they approach debugging in their daily work.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Discuss Design Principles Like SOLID:&lt;/strong&gt; Well-designed C# code properly implements key object-oriented principles and design patterns. Dive into their knowledge of topics like the single-responsibility principle, inversion of control/dependency injection, and others.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Explore Language Internals:&lt;/strong&gt; Developers working extensively with C# should have an advanced grasp of how the language itself functions under the hood - topics like memory management, garbage collection, extension methods, etc. Pose questions that demonstrate their understanding of internal processes.
The aim is to give them opportunities to show competence across a spectrum of important C# coding concepts and practical techniques. If they struggle with basic language features or stumble on realistic problems, that should raise flags about gaps in their skills.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Explore Their .NET and Related Knowledge
&lt;/h2&gt;

&lt;p&gt;C# does not exist in a vacuum. Experienced C# developers should have knowledge of the key frameworks, libraries and ecosystems that play important roles in building .NET applications.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;ASP.NET:&lt;/strong&gt; For web development, understanding ASP.NET and frameworks like ASP.NET Core is crucial. See if they have experience building web forms and MVC applications. Ask about Razor Pages, dependency injection, EF Core, authentication/authorization, and other common components of the stack.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Windows Desktop Development:&lt;/strong&gt; Windows Forms and WPF are used for building traditional desktop GUI apps. While less common today, these are still relevant skills. Have they worked on WinForms or WPF apps in past roles? What UI development tools and patterns are they familiar with?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Unit Testing:&lt;/strong&gt; Writing unit tests is a key part of professional C# development. Quiz them on their knowledge of frameworks like MSTest, NUnit, and xUnit. See if they follow Test Driven Development (TDD) principles in their work.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Asynchronous Programming:&lt;/strong&gt; C# developers should understand async/await patterns for building responsive applications. Ask how they implement long-running processes without blocking execution threads. What experience do they have with Task objects?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Object-Relational Mapping:&lt;/strong&gt; Most applications need to interface with databases, and ORM tools like Entity Framework Core facilitate this. Check if they have configured EF Core contexts and built repositories/services for data access.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;REST APIs:&lt;/strong&gt; Consuming and creating REST-based web APIs is near-universal. Do they have hands-on experience with API concepts like endpoints, verbs, authentication, and OpenAPI/Swagger documentation? Have they built web APIs from scratch?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cloud Platforms:&lt;/strong&gt;  Services like Azure, AWS, and GCP are mainstream today. See if they have exposure deploying or managing .NET applications on these platforms, using services like App Services, Functions, and VMs.
The wide .NET ecosystem greatly expands what developers can build with C#. Experience applying related technologies and libraries is a must for senior roles.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Learn About Past Projects and Accomplishments
&lt;/h2&gt;

&lt;p&gt;Another perspective into candidates' capabilities comes from the actual projects they have built and led using C#.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Examples of Complete Apps or Complex Features:&lt;/strong&gt; Have they designed and built an entire application from the ground up with C#? Maybe for a past employer or as a personal project? Understanding the scope and complexity provides insights into their ability to put concepts into practice.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Project Challenges:&lt;/strong&gt; No major project is without roadblocks. What difficult problems did they encounter? How did they react to unexpected issues arising? What did they learn in the process?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Team Dynamics:&lt;/strong&gt; Most developers work on teams. Did they play a lead role in defining architecture and making technical decisions? Or were they mainly focused on heads-down coding? Explore project leadership skills.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Components they Developed:&lt;/strong&gt; On large codebases spread across teams, dig into the specific components, services, and features they own building. This demonstrates their exact coding responsibilities and skills.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Source Control Processes:&lt;/strong&gt; Ask how they use Git and GitHub/Azure DevOps to collaborate on code projects. Do they use proper branching strategies and PR workflows?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Code Reviews:&lt;/strong&gt; How are they involved with reviewing and providing feedback on other developers' code? This builds shared code health and quality standards across teams.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Documentation:&lt;/strong&gt; In addition to writing code, do they help create technical spec documents, API references, inline comments, wiki pages, release notes, and other artifacts commonly worked on by developers?
The better the grasp they have on the end-to-end development process, the stronger indication it is of their capabilities and experience&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Final Words
&lt;/h2&gt;

&lt;p&gt;Evaluating C# and &lt;a href="https://positiwise.com/technologies/dot-net-development"&gt;.NET Development&lt;/a&gt; skills thoroughly during interviews takes thoughtful planning and preparation. But it’s time well spent to ensure you are making informed hiring decisions. By reviewing resumes, diving into education and training, conducting coding exercises, discussing .NET ecosystem knowledge, and exploring past projects, you can assemble a complete picture of a developer's abilities.&lt;br&gt;
Keep in mind that very few candidates will check every box across the spectrum of potential topics. The goal is not to find some mythical "perfect" applicant. Instead, aim to use the interview process to filter for developers who meet the key skill bar for your specific team and projects. With rigorous C# interview practices in place, you'll avoid bad hiring mismatches and assemble a strong development team.&lt;/p&gt;

&lt;h2&gt;
  
  
  Related Resources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://dev.to/me_janki/the-5-most-common-mistakes-in-c-and-net-programming-with-solutions-kjd"&gt;The 5 Most Common Mistakes in C# and .Net Programming with Solutions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/me_janki/tips-to-use-master-reports-in-your-c-net-application-4d6"&gt;Tips to Use Master Reports in Your C# .NET Application&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/me_janki/converting-excel-xlsx-to-pdf-with-c-net-625"&gt;Converting Excel XLSX to PDF with C# .NET&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>csharp</category>
      <category>dotnet</category>
      <category>aspnet</category>
      <category>programming</category>
    </item>
    <item>
      <title>Connecting Two Web Forms in ASP.NET</title>
      <dc:creator>Janki Mehta</dc:creator>
      <pubDate>Fri, 10 Nov 2023 06:47:52 +0000</pubDate>
      <link>https://forem.com/me_janki/connecting-two-web-forms-in-aspnet-3dp8</link>
      <guid>https://forem.com/me_janki/connecting-two-web-forms-in-aspnet-3dp8</guid>
      <description>&lt;p&gt;Connecting multiple web forms together is a common requirement in ASP.NET web applications. For example, you may want to pass data or values from one form to another after submitting the first form. There are a few different ways to accomplish this in ASP.NET.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using Session State
&lt;/h2&gt;

&lt;p&gt;One method is to use the ASP.NET session state to store values from the first form and then retrieve them on the second form. Here are the steps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;On the first web form (Form1.aspx), save any values you want to pass to the next form in the Session state. For example:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;protected&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;Button1_Click&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;object&lt;/span&gt; &lt;span class="n"&gt;sender&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;EventArgs&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;Session&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"UserName"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;TextBox1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;Session&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"Email"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;TextBox2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;After handling the postback on Form1, redirect to the second web form:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="n"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Redirect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Form2.aspx"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;In the page load event on the second web form (Form2.aspx), retrieve the values from Session state:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;protected&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;Page_Load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;object&lt;/span&gt; &lt;span class="n"&gt;sender&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;EventArgs&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(!&lt;/span&gt;&lt;span class="n"&gt;IsPostBack&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;userName&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Session&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"UserName"&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;ToString&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;email&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Session&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"Email"&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;ToString&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

    &lt;span class="c1"&gt;//populate form controls with session values&lt;/span&gt;

  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It allows you to pass data between the two forms through session state.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using Query String Parameters
&lt;/h2&gt;

&lt;p&gt;Another approach is to pass data between forms using query string parameters.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;On the first form, append the values you want to pass as query string parameters to the redirect URL:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="n"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Redirect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Form2.aspx?name="&lt;/span&gt; &lt;span class="p"&gt;+&lt;/span&gt; &lt;span class="n"&gt;TextBox1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Text&lt;/span&gt; &lt;span class="p"&gt;+&lt;/span&gt; &lt;span class="s"&gt;"&amp;amp;email="&lt;/span&gt; &lt;span class="p"&gt;+&lt;/span&gt; &lt;span class="n"&gt;TextBox2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;On the second form, retrieve the query string values in the page load event:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;protected&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;Page_Load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;object&lt;/span&gt; &lt;span class="n"&gt;sender&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;EventArgs&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  
&lt;span class="p"&gt;{&lt;/span&gt;

  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(!&lt;/span&gt;&lt;span class="n"&gt;IsPostBack&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;QueryString&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
    &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;email&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;QueryString&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"email"&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

    &lt;span class="c1"&gt;//populate controls &lt;/span&gt;

  &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The benefit of this approach is it avoids use of server-side state. The downside is the query string can be tampered with by the user.&lt;/p&gt;

&lt;h2&gt;
  
  
  Posting Form Data Via Cross-Page Posting
&lt;/h2&gt;

&lt;p&gt;A third approach is to use cross-page posting to submit the form values from the first page directly to the second page. Here is how this works:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Set the PostBackUrl property on the submit button on Form1 to the URL of Form2:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;asp:Button&lt;/span&gt; &lt;span class="na"&gt;ID=&lt;/span&gt;&lt;span class="s"&gt;"Button1"&lt;/span&gt; &lt;span class="na"&gt;runat=&lt;/span&gt;&lt;span class="s"&gt;"server"&lt;/span&gt; &lt;span class="na"&gt;Text=&lt;/span&gt;&lt;span class="s"&gt;"Submit"&lt;/span&gt; &lt;span class="na"&gt;PostBackUrl=&lt;/span&gt;&lt;span class="s"&gt;"Form2.aspx"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;On Form2.aspx, the posted form values from Form1 will be available in Request.Form in the page load event:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;protected&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;Page_Load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;object&lt;/span&gt; &lt;span class="n"&gt;sender&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;EventArgs&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;

  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(!&lt;/span&gt;&lt;span class="n"&gt;IsPostBack&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Form&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"TextBox1"&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
    &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;email&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Form&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"TextBox2"&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

    &lt;span class="c1"&gt;//populate controls&lt;/span&gt;

  &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It submits the form values directly from one page to the other without redirects.&lt;/p&gt;

</description>
      <category>aspnet</category>
      <category>aspdotnet</category>
      <category>webform</category>
      <category>programming</category>
    </item>
    <item>
      <title>How to Develop and Deploy Fast Applications With Vite JS</title>
      <dc:creator>Janki Mehta</dc:creator>
      <pubDate>Tue, 07 Nov 2023 10:51:56 +0000</pubDate>
      <link>https://forem.com/me_janki/how-to-develop-and-deploy-fast-applications-with-vite-js-7km</link>
      <guid>https://forem.com/me_janki/how-to-develop-and-deploy-fast-applications-with-vite-js-7km</guid>
      <description>&lt;p&gt;Vite has rapidly become one of the most popular open-source front-end build tools. Its main selling points are nearly instantaneous server start and hot module replacement (HMR). Let's dive into how we can leverage Vite to develop and deploy blazing-fast web applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Vite.js?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://dev.to/me_janki/learn-how-to-boost-web-development-with-vitejs-a-step-by-step-guide-50l2"&gt;Vite.js is a front-end build tool&lt;/a&gt; that aims to provide a faster and leaner development experience. It was created by Evan You, the author of popular frameworks like Vue.js.&lt;/p&gt;

&lt;p&gt;Vite builds on top of native ES Module imports instead of bundles like Webpack. This allows it to serve source code over a development server extremely quickly. The production build pre-bundles your code for optimal loading in the browser.&lt;/p&gt;

&lt;p&gt;Some key features that make Vite stand out include:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Instant Server Start&lt;/strong&gt;&lt;br&gt;
Vite achieves near-instant server start by serving source code over native ESM. There is no bundling required for development, so the server starts instantly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hot Module Replacement&lt;/strong&gt;&lt;br&gt;
Changes made to source files during development are reflected instantly in the browser without full page reloads. This is made possible by its HMR implementation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Use Vite for App Development?
&lt;/h2&gt;

&lt;p&gt;There are several compelling reasons to use Vite for web app development:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Blazing Fast Build Speeds&lt;/strong&gt;&lt;br&gt;
Production builds with Vite are extremely fast. It pre-bundles your app code intelligently, resulting in smaller bundle sizes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rich Ecosystem and Tooling&lt;/strong&gt;&lt;br&gt;
Vite has first-class support for frameworks like React, Vue, and Svelte. There is also a robust plugin ecosystem.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Easy Migration from Create React App&lt;/strong&gt;&lt;br&gt;
For React apps, moving from Create React App to Vite is quite straightforward. This makes it easy to migrate existing apps to Vite.&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting Started with Vite
&lt;/h2&gt;

&lt;p&gt;It's simple to get up and running with Vite. We'll cover the basics of installation, project setup, and the development workflow.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Installation and Setup&lt;/strong&gt;&lt;br&gt;
To &lt;a href="https://positiwise.com/blog/how-to-install-vite-js-on-your-computer"&gt;install Vite.js on your computer&lt;/a&gt;, we need Node.js. Then we can scaffold a new project by running:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm init vite@latest&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This will prompt us to select a framework and provide other project details.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Project Structure Overview&lt;/strong&gt;&lt;br&gt;
The generated project structure is clean and minimal. The main files and folders are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;index.html&lt;/code&gt; - The HTML entry point&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;src/&lt;/code&gt; - Contains our source code&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;src/main.js&lt;/code&gt; - The JavaScript entry point&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;src/App.vue&lt;/code&gt; - The main app component (for Vue apps)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Development Workflow&lt;/strong&gt;&lt;br&gt;
To start the dev server, just run:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm run dev&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This will serve your app at localhost:5173 by default.&lt;/p&gt;

&lt;p&gt;Now, let's go over some key aspects of development with Vite:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Starting the Dev Server&lt;/strong&gt;&lt;br&gt;
The Vite dev server starts up instantly. You can begin coding immediately and see changes reflected in the browser immediately.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Native ESM Support&lt;/strong&gt;&lt;br&gt;
Importing JavaScript modules just works out of the box. No complex configuration is needed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Working with Assets&lt;/strong&gt;&lt;br&gt;
Importing CSS, images, fonts, etc from JavaScript also works seamlessly. Vite handles assets extremely well.&lt;/p&gt;

&lt;h2&gt;
  
  
  Building and Deploying Vite Apps
&lt;/h2&gt;

&lt;p&gt;Let's explore how to build and deploy apps made with Vite.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Production Build&lt;/strong&gt;&lt;br&gt;
To generate a production build, run:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm run build&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This will bundle and minimize your code with sensible defaults.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Build Options&lt;/strong&gt;&lt;br&gt;
The build can be customized via the vite.config.js file. For example, we can set the base URL for the app here.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Advanced Configurations&lt;/strong&gt;&lt;br&gt;
Vite lets you fine-tune the build output in great detail via its API and plugins. This flexibility is useful for complex apps.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Deployment&lt;/strong&gt;&lt;br&gt;
Vite apps can be deployed in multiple ways:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Static Hosting&lt;/strong&gt;&lt;br&gt;
The built dist folder can be directly deployed to any static hosting service like Netlify or Vercel.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Server-Side Rendering&lt;/strong&gt;&lt;br&gt;
For SSR with Node or Deno servers, Vite provides SSR helpers and Nuxt.js integrations.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Vite enables rapid front-end development by leveraging native ESM imports. With its fast dev server, HMR, and optimized builds, it's a great choice for modern web apps. The intuitive project scaffolding, familiar workflow, and rich plugin ecosystem further make Vite a go-to build tool.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is the difference between Vite and Webpack?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Vite uses native ESM imports and serves source code over a dev server. Webpack bundles all code into static assets during development. Vite has faster startup and HMR.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How does Vite achieve fast HMR?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Vite maintains a persistent WebSocket connection to the browser to handle HMR updates. Code changes are streamed over this connection, avoiding full browser refreshes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Can Vite be used with existing projects?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Yes, Vite can replace the build setup in most existing projects with its framework integration. For React, the @vitejs/plugin-react plugin handles JSX transformation similar to Babel.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What browsers does Vite support?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Vite supports browsers that implement native ESM imports (Chrome, Firefox, Edge). For legacy browser support, code is transpired, and polyfills are added during the build step.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Does Vite fully replace Webpack?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Vite is optimized for modern browser apps. For legacy browser support, integration with Webpack is still useful. The two can complement each other in some cases.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>developers</category>
      <category>vite</category>
      <category>javascript</category>
    </item>
    <item>
      <title>How to Save a Node.js Script</title>
      <dc:creator>Janki Mehta</dc:creator>
      <pubDate>Mon, 06 Nov 2023 05:57:41 +0000</pubDate>
      <link>https://forem.com/me_janki/how-to-save-a-nodejs-script-5em1</link>
      <guid>https://forem.com/me_janki/how-to-save-a-nodejs-script-5em1</guid>
      <description>&lt;p&gt;Node.js allows you to write JavaScript code that runs outside of a browser. This code is often saved in .js files that can be executed from the command line. Here are a few ways to save and run a Node.js script:&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Create a .js File
&lt;/h2&gt;

&lt;p&gt;To save a Node.js script, simply create a new text file with a .js extension. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;myScript&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;js&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can create this in any text editor like Visual Studio Code, Sublime Text, Atom, etc.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Add Node.js Code
&lt;/h2&gt;

&lt;p&gt;In the .js file, write your Node.js code. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;msg&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hello World&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;msg&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This script logs "Hello World" to the terminal.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Save the File
&lt;/h2&gt;

&lt;p&gt;Be sure to save the .js file in your project directory. For example, you may have a scripts folder where you save all your Node.js scripts.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Run the Script
&lt;/h2&gt;

&lt;p&gt;To execute the script, open your terminal and navigate to the script directory. Then run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;node&lt;/span&gt; &lt;span class="nx"&gt;myScript&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;js&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It will execute the code in myScript.js. You should see "Hello World" output to the terminal.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Export and Import Scripts
&lt;/h2&gt;

&lt;p&gt;You can also export code from one script and import it into another file. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// myFunctions.js&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;greeting&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hello&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// main.js &lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;greeting&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./myFunctions.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nx"&gt;greeting&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// Logs "Hello"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It allows you to organize your code into reusable modules.&lt;/p&gt;

&lt;p&gt;Saving a Node.js script is as simple as creating a .js file and running it with node. This allows you to write and execute JavaScript code outside of the browser!&lt;/p&gt;

</description>
      <category>node</category>
      <category>javascript</category>
      <category>programming</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
