Server-Sent Events in ASP.NET Core for Real-Time Push Notifications

 public DataTable GetUserIdForNotification(string ContentId, string userId, CommentType ContentTypeId)
 {
     var dt = new DataTable();
     dataBase = new Database();
     param = new SqlParameter[3];
     try
     {
         param[0] = dataBase.MakeInParameter("@ContentId", SqlDbType.VarChar, 100, ContentId);
         param[1] = dataBase.MakeInParameter("@UserID", SqlDbType.VarChar, 50, userId);
         param[2] = dataBase.MakeInParameter("@ContentTypeId", SqlDbType.Int, 4, Convert.ToInt32(ContentTypeId));
         dataBase.RunProcedure("GetUserIdForSendNotification", param, out dt);
         return dt;
     }
     catch (Exception exp)
     {
         logger.Error(exp.ToString());
         return null;
     }
     finally
     {
         Reset();
     }
 }

The first programming language I dabbled in before launching my career as a software engineer was Visual Basic 2, released in November 1992. What initially drew me to the language and its Integrated Development Environment (IDE) was the seamless experience of creating applications. With VB2, crafting Windows applications was a breeze; I could simply drag and drop user controls onto a Form, shaping the user experience effortlessly. We refer to this as WYSIWYG (What You See is What You Get). This user-friendly approach has kept me loyal to Microsoft programming languages, even into 2024.

Microsoft allowed us to create Windows DOS applications with WYSIWYG when it released Visual Basic for DOS in 1991. I created my first multi-platform application for General Atomics in San Diego, California, using Visual Basic and Visual Basic for DOS! Back then, I couldn’t share common code like we can now with Microsoft .NET, but both versions had the same features. This application was the very first PC-based phonebook application to look up employees at General Atomics. I still have the installation disks for VB for DOS. It only lasted for two releases.

I created the first applications that I made available to the public via BBS systems using Visual Basic 3 in 1993. One of those applications, Same<>Same, was even reviewed by PC Magazine, which dramatically helped with selling it for a time. Besides Same<>Same, I released multiple screen savers and other utility applications. I charged money for Same<>Same and the screen savers!

Microsoft Access was released in 1992 and is the database management system (DBMS) for the Microsoft Jet Database Engine. The biggest feature of Access was its data entry and management, which allows users to visually design tables, define relationships between tables, and create data entry forms. This made it very easy to create databases and UI to maintain that data, and it's still in use today. Now it’s part of Microsoft Office.

Then, in October of 1995, Microsoft introduced FrontPage, featuring a WYSIWYG HTML editor and website administration tool. Although I began crafting personal websites with Notepad, I swiftly transitioned to FrontPage upon its release. It even streamlined site updates with just the press of a button. I used FrontPage for my very first website called VBTT.com (Visual Basic Tips & Tricks), which is now dotNetTips.com (.NET Tips & Tricks) and is now created and maintained with WordPress.

In September 1996, Microsoft unveiled Visual InterDev, which brought the same ease of use to website creation using an IDE by introducing Active Server Pages (ASP). Visual InterDev offered server-side scripting, database connectivity, Visual SourceSafe integration, debugging support, web server management, and integration with FrontPage. Like Visual Basic and FrontPage, Visual InterDev facilitated drag-and-drop web form creation using WYSIWY.

I used Visual InterDev to create websites for the companies I worked for until Microsoft .NET and ASP.NET came out. If you talk to anyone who used it, I’m sure their face might cringe from their experience. It wasn’t the easiest IDE to use, but it laid the foundation for what became ASP.NET.

Fast forward to February 2002, with the release of Microsoft .NET, which introduced a new IDE called Visual Studio. Visual Studio combined the best aspects of Visual Basic, Visual C++, and Visual InterDev to create one of the most powerful IDEs for software application development. ASP.NET was released with .NET, which dramatically sped up the creation of websites and web services. Alongside a robust code editor, Visual Studio enabled the creation of Windows and web forms through drag-and-drop, expediting application development. While doing it all with code is an option, the IDE significantly hastened the process, allowing for the rapid creation of prototypes and applications. I’m not sure if younger developers realize that you don’t need any IDE to create .NET applications, but it sure makes you a thousand times more productive!

Another notable addition to Visual Basic 6 and Visual Studio was IntelliSense, which provided code completion and suggestions. While I'm a huge fan of IntelliSense, I acknowledge that it might contribute to retaining less information. However, given the complexities of modern software engineering, relying solely on memory isn't practical.

I’ve always felt that one of the goals of Visual Studio is to allow the developer to use just one IDE for all their daily programming tasks and it does accomplish that. Not only does it provide all your programming needs, but it also allows you to create and maintain databases, cloud services, containers, source control repositories, build and deploy releases, and a lot more. On top of that, Visual Studio allows anyone to create add-ins to the application that provide better features or features that are not part of the IDE.  These add-ins and frameworks allow us to create applications even faster with more features, with some requiring no code at all.

Visual Studio also guides developers to create better, more robust applications. In the early days of .NET, many of us used FxCop and StyleCop to accomplish that. With the release of Roslyn and the later versions of .NET, Visual Studio Analyze along with the EditorConfig files has replaced FxCop and StyleCop by providing a static code analysis tool. In 2021, CoPilot was introduced to Visual Studio which provides AI-powered assistance to developers while writing code.

I have written and mentioned live at my conference talks many, many times that writing high-quality performant code the first time will result in fewer bugs, use the latest standards, and is a lot cheaper than fixing it later, thus allowing companies to spend more time on features to attract and keep users. That is why I welcome the assistance of AI. Again, it will allow developers to write less code and focus on features. Features sell applications and services, not code, bug fixes, or performance enhancements!

In April 2015, Microsoft came out with a free IDE called Visual Studio Code. VS Code is a lightweight but powerful source code editor that works on Windows, macOS, and Linux, supports a wide array of languages, and makes writing scripts easier too. VS Code is very flexible and customizable using extensions (like the extensions in Visual Studio). After using Visual Studio for 16 years before VS Code was released, I still use Visual Studio. To me, it's much more robust and requires very little or no configuration to start writing apps. VS Code can’t match the enterprise features of Visual Studio, especially since most of the extensions I use daily are not available in VS Code.

This article is a “brief” history of IDEs provided by Microsoft. I’ve discussed the ones I have used the most during my career, but there are many more. Here is just a small list of the more popular ones:

  • Visual C++ (1993): IDE from Microsoft for C and C++ that features a code editor, compiler, linker, debugger, and project management capabilities.
  • SQL Server Management Studio (2005): Integrated environment for managing any SQL infrastructure, from SQL Server to Azure SQL Databases.
  • Azure Storage Explorer (2013): Allows you to easily work with Azure Storage data on Windows, macOS, and Linux.
  • Power BI (2015): Allows users to visualize and analyze data, create interactive reports and dashboards, and share insights across their organization. Power BI integrates with a wide range of data sources, including Excel spreadsheets, databases, cloud services, and streaming data sources.
  • Azure Data Studio (2018): Cross-platform database tool for cloud data platforms on Windows, macOS, and Linux.

Do You Prefer IDEs or the CLI?

The choice between using an IDE or not often feels like a religious decision these days, with some vehemently favoring one over the other. However, I believe in a hybrid approach to .NET development. Programmers can opt for manual coding, use an IDE, or leverage both methods. Considering the intricacies of software engineering, utilizing the IDE for efficiency in application development is paramount. However, engineers need to familiarize themselves with CLI commands for scenarios where IDE functionality falls short.

Even when I was a lot younger in the 90s, I struggled to remember all the commands a CLI might offer. For instance, XCopy for DOS comprises 15 commands, while the dotnet CLI also consists of 15 commands, with 'build' alone featuring over 20 commands. IDEs alleviate the burden of memorizing these commands, expediting application delivery. Nevertheless, engineers should invest time in learning CLI commands for situations requiring functionalities beyond the IDE's scope.

Ebook Download
View all
milton
Read by 0 people
Download Now!
Learn
View all