Quote of the Day

more Quotes

Categories

Buy me a coffee

Deploy an ASP.NET core application to IIS on Windows Server 2019.

Published March 16, 2019 in ASP.NET core , Devops , IIS - 4 Comments

This is part II of the blog post series in which I share some of ways to build and deploy an ASP.NET core application to IIS running on a Windows VM. In the previous post, I cover how to build and published an ASP.NET core application. The end result is an artifact (a published directory). In this post, I go over how to deploy the artifact to IIS. Along the way, we’ll discuss:

  • Enabling IIS
  • .NET core runtime and hosting bundle
  • IIS website and application configuration
  • IIS application pool

Continue reading

Build and publish an ASP.NET core application using Visual Studio.

Published March 4, 2019 in ASP.NET core , Devops - 2 Comments

This is part I of the blog post series in which I share some of the ways I have learned to build and deploy an ASP.NET core 2 application to IIS running on Windows Server VM.

In this post, we’ll cover just the basics of how to build and publish an ASP.NET core 2 application to a folder using Visual Studio 2017. In the process, we’ll discuss some of the concepts you should be familiar with:

  • Release vs Debug build.
  • Deployment mode: framework dependent deployment vs self contained deployment.

I assume you have a working ASP.NET core application which you want to deploy. If not, you can just create a new ASP.NET core project, following the documentation.

Continue reading

Azure queue storage: overview, benefits and usage in .NET/ .NET core application.

Published January 20, 2019 in Azure - 2 Comments

I have seen applications which use a database to simulate a queue as part of processing some workflow tasks. Using a database to simulate a messaging queue mean you have to write more boilerplate codes, sql queries for the CRUD operations as well as handle concurrency issues if your applications run on multiple nodes.

Microsoft has made it easy to utilize messaging and queueing in your application with azure queue storage, which is what I talk about in this post.

Continue reading

Don’t use string when working with dates in javascript/angular and .NET

Published December 10, 2018 in .NET , Angular , Javascript - 3 Comments

Sometimes,  I have seen developers (myself included) use simple strings to represent dates. This could lead to unexpected behaviors if you are not careful. For instance, I recently ran into a bug where the PDF document the program generated show the incorrect date, which was a few hours off from the correct one. The date value originated from a data API and did not include a timezone. The intended time zone was  local time, which is Pacific Standard Time (PST) in this case. However, because we were using storing the date in the angular application using string instead of the javascript built-in Date type, when the framework serialized the data into JSON and sent to .NET, it kept the date as is and did not add any timezone. At the backend, .NET deserialized the value back into a DateTime object, and when we attempted to convert the value to local time usingDateTime.ToLocalTime()for displaying in the document, we got an incorrect value because .NET assumed the date was in Universal Coordinated Time (UTC). 

The bug was because of inconsistencies when passing date values and not including timezone information. However, had we used the frameworks’ built-in types for representing dates instead of strings, we could have avoided the issue. 

Continue reading

How to auto start and keep an ASP.NET core web application running on IIS

Published October 7, 2018 in ASP.NET core , IIS - 26 Comments

I have an ASP.NET core web application which hosts a background task via the IHosedService interface. I wrote about it in this post, if you want more info. The task needs to run continuously to poll for messages on an azure queue storage every 5 seconds. I have learned the default settings on IIS do not start the application until it receives the first request. Additionally, if the application has not received a request after a predefined period of time, IIS kills the application.

I could have hosted the application as a Windows service or converted the application into a console application and use the Windows scheduler to have it run continuously. However, I find hosting on a real IIS server convenient and beneficial since we already have other applications running on IIS and we can access the application via HTTP.

In this post, I share how I make the application to auto start and always run on IIS.

If you have an ASP.NET or an ASP.NET core which hosts a background job that needs to always run, want to preload the application for performance instead of waiting for the initial request to hit the app, or just get some tips on IIS, then read on.

Continue reading