How to Use Web.Config customErrors for ASP.NET

Matt Watson Developer Tips, Tricks & Resources, Live Queue Leave a Comment

The ASP.NET framework provides built-in settings to control how to respond when an application error occurs. This functionality is part of the Web.Config customErrors section. Configuration Options for Web.Config <customErrors> Like most web.config settings, customErrors can be configured within the Machine.config, root web.config or your application web.config file. Usually, it is set per application. CustomErrors supports the following modes: On – …

Best Practices for Error Handling in ASP.NET MVC

Matt Watson Developer Tips, Tricks & Resources, Live Queue Leave a Comment

Error handling is an important part of any application. ASP.NET provides several different ways to handle errors. In this article, we will review MVC error handling best practices. 5 Ways to do MVC Error Handling Between .NET, ASP.NET, and MVC there are several potential ways to handle application errors. Web.Config customErrors MVC HandleErrorAttribute Controller.OnException method HttpApplication Application_Error event Collect exceptions via …

What is NullReferenceException? Object reference not set to an instance of an object

Matt Watson Developer Tips, Tricks & Resources, Live Queue Leave a Comment

Null reference errors are responsible for a good percentage of all application bugs. They are usually very simple problems caused by not adding additional logic to ensure that objects have valid values before using them. The following code will throw a NullReferenceException if the variable “text” being passed in is null. You can’t call ToUpper() on a null string. public …

Understanding # of Exceps Thrown / Sec, and How to Find Exceptions

Matt Watson Developer Tips, Tricks & Resources, Live Queue Leave a Comment

Exceptions can cause big performance problems. One of the most important performance metrics to track about your application is “# of Exceps Thrown / Sec“. It is available via Windows Performance Counters under the category .NET CLR Exceptions. In this article we will talk about exceptions, how to monitor your exception rate and find the actual exceptions being thrown. Is …

How to Generate C# Random Numbers, Pseudo vs Secure Random Numbers

Matt Watson Developer Tips, Tricks & Resources, Live Queue Leave a Comment

Random numbers are used in a wide variety of software applications. Depending on what you are using random numbers for, you will need to decide which type to use. For a music jukebox, the accuracy is not very critical. For something like a lottery or slot machine, the random number generator must be extremely accurate. There are two types of …

What is an Unhandled Exception, and How to Catch All C# Exceptions

Matt Watson Developer Tips, Tricks & Resources, Live Queue Leave a Comment

What is an Unhandled Exception? An exception is a known type of error. An unhandled exception occurs when the application code does not properly handle exceptions. For example, When you try to open a file on disk, it is a common problem for the file to not exist. The .NET Framework will then throw a FileNotFoundException. This is a simple example …

How to Deploy ASP.NET Core to IIS & How ASP.NET Core Hosting Works

Matt Watson Developer Tips, Tricks & Resources, Live Queue Leave a Comment

Previously, I discussed the differences between Kestrel vs IIS. In this article, we will review how to deploy an ASP.NET Core application to IIS. Deploying an ASP.NET Core app to IIS isn’t complicated, but ASP.NET Core hosting is a little different than ASP.NET. How to Configure Your ASP.NET Core App For IIS The first thing you will notice when creating …

ASP.NET Core Web Servers: Kestrel vs IIS Feature Comparison and Why You Need Both

Matt Watson Developer Tips, Tricks & Resources, Live Queue Leave a Comment

The Kestrel web server is a new web server as part of ASP.NET Core. It is now the preferred web server for all new ASP.NET applications. In this article, we will review what it is, how to use it, and the differences between Kestrel vs IIS. Why Do We Need the New Kestrel Web Server? What about IIS? If you have …

Software Error vs Exception – In Real World Examples

Matt Watson Developer Tips, Tricks & Resources, Live Queue Leave a Comment

After 15+ years of software development, I still use the words error and exception interchangeably. But is there a difference between exceptions and errors? I think it is best to make the distinction with some examples of errors vs exceptions. Example #1: Dishwasher Errors Let’s use this example of a dishwasher. Both images depict a problem, or error, that happened with …

Where Are IIS Log Files Located? How to View IIS Logs on Windows & Azure

Matt Watson Developer Tips, Tricks & Resources, Live Queue Leave a Comment

Not sure where your IIS log files are located? No problem! For a standard Windows Server, the default log location is: %SystemDrive%\inetpub\logs\LogFiles If your IIS logs are not stored in the default location, follow these directions below to look up where they are currently being stored. We also have directions below for Azure App Services & Cloud Services. Where Are …

How to Troubleshoot IIS Worker Process (w3wp) High CPU Usage

Matt Watson Developer Tips, Tricks & Resources, Live Queue Leave a Comment

Having problems with w3wp.exe high CPU usage? In this article, we will discuss some tips to identify what is causing high CPU usage for your ASP.NET web application. There are a lot of reasons that your IIS worker process (w3wp.exe) could be using a lot of CPU. We will cover some of the top reasons and how to troubleshoot them. To …

C# Exception Handling Best Practices

Matt Watson Developer Tips, Tricks & Resources, Live Queue Leave a Comment

Welcome to Stackify’s guide to C# exception handling. In this article we cover the following topics: Basics about C# Exceptions, including examples Common .NET Exceptions How to Create Your Own Custom C# Exception Types How to Find Hidden .NET Exceptions C# Exception Logging Best Practices What is an Exception? Exceptions are a type of error that occurs during the execution …

What is w3wp.exe? Learn the Basics About IIS Worker Processes

Matt Watson Developer Tips, Tricks & Resources, Live Queue Leave a Comment

Web applications running within Microsoft’s Internet Information Services (IIS) utilize what is known as IIS worker processes. These worker processes run as w3wp.exe, and there can be multiple per computer. It is possible to run IIS on a Windows desktop or Windows server, although it is usually only seen on Microsoft Windows Servers configured as web servers. What is w3wp.exe …

How to Create .NET Core Windows Services with Visual Studio 2017

How to Create .NET Core Windows Services with Visual Studio 2017

Matt Watson Developer Tips, Tricks & Resources Leave a Comment

Mobile and web applications might be all the rage these days, but a lot of the real work still gets done via background services and scheduled tasks. At Stackify, we use a lot of background .NET services for processing all of the data that our systems ingest. One of the common problems with .NET Core when it first came out was …

3 Key DevOps Needs for Every Development Team

3 Key DevOps Needs for Every Development Team

Matt Watson Developer Tips, Tricks & Resources, Insights for Dev Managers Leave a Comment

Agile development has created a process for developers to rapidly ship a new version of their code. DevOps is the next step in the process. It is the ability to help get that code to production as fast as possible. What do development teams need to embrace DevOps? DevOps should be about empowering your development team to be able to do …

What is DevOps?

What is DevOps? – Give Your Development Team Ownership

Matt Watson Developer Tips, Tricks & Resources, Insights for Dev Managers Leave a Comment

DevOps has been a hot topic for the last several years. I have always had a love/hate relationship with the term. Most argue it as all about team culture and collaboration. Vendors have done everything they can to latch their products onto the DevOps bandwagon. As you will read below, I have my own opinion about what is DevOps and …