Posts

Create a calendar invite (ics file) in ASP NET

Creating a calendar invite (ics file) and attaching a email via service or sending an email with downloadable calendar invite is what we are going to learn in following posts. In this post, I will show how you can use ICal library from Nuget and create a calendar invite. The calendar begins with the keyword  BEGIN:VCALENDAR  and ends with  END:VCALENDAR . In between the calendar you can add as many events as you want beginning each event with  BEGIN:VEVENT  and ending with  END:VEVENT . There is a catch when adding multiple events to a calendar, and that is the type of METHOD you use. With METHOD:PUBLISH, you can add multiple events and upon opening the iCal with MS Outlook it will create a new calendar, separate from your main Exchange calendar. METHOD:REQUEST creates a calendar invite, so you can only include one event and upon opening with MS Outlook it will ask you to accept the event and add it to your main Exchange calendar. With this method you have to include the organizer

Serve GZip CSS and JS from AWS S3

Amazon Simple Storage Service (Amazon S3) is an object storage service that offers industry-leading scalability, data availability, security, and performance. This means customers of all sizes and industries can use it to store and protect any amount of data for a range of use cases, such as websites, mobile applications, backup and restore, archive, enterprise applications, IoT devices, and big data analytics. If you are looking to gzip  your static JS and CSS when hosting on S3, however, it’s not obvious how to do so, and results often bring up other AWS hosting services as well. Here’s the quick and simple way to serve gzipped JS and CSS from AWS S3. S3 needs those files compressed before they are uploaded, it can’t do the actual gzipping for us. This is done with a simple command, which I recommend be added as a script to your build step, or your continuous integration process. gzip -9 /filepath/bootstrap.js or gzip -9 /filepath/bootstrap.css The -9 denotes that we want the

Create windows services in C#

In this blog post, we will go over on how to create windows services in C#. Windows services are started when OS boots and runs the service in the background. It can start automatically or can be made to start, stop or run based on manual trigger. Here is how you can create your own windows service: Open Visual Studio, go to File > New and select Project. Go to Visual C# -> ”Windows Desktop” -> ”Windows Service,” give your project an appropriate name and then click OK. Once you click OK, there will be a black screen with Service1.cs[design] file opened. Now, right click on a blank area, and select Add Installer. We need to add installers to windows service before you run the service, which registers with service control managers. After adding installer, it adds ProjectInstaller.cs to the project. Once you view the code of Project Installer, you would see InitialiseComponent method. Once you go to the definition of it, here you can mention the name of service, descripti

Enable CORS with a dynamic list of origins

Minification of HTML in ASP.NET

Minification refers to the process of removing unnecessary or redundant data without affecting how the resource is processed by the browser – e.g. code comments and formatting, removing unused code, using shorter variable and function names, and so on.. In today’s post, we are gonna quickly learn how to minify HTML for Asp.Net. We will Minify the HTML produced by  ASP.NET  by using an HttpModule  to remove all white spaces from the Response Stream. First lets create the  Filter  for removing the white spaces using System; using System.IO; using System.Text; using System.Text.RegularExpressions; namespace HtmlMinification { internal class WhitespaceFilter : Stream { private static readonly Regex Pattern = new Regex(@"^\s+", RegexOptions.Multiline | RegexOptions.Compiled); private readonly Stream _stream; public override bool CanRead { get { return true; } } public override bool CanSeek {

Creating a NuGet Package

MSBuild Structured Log