Middleware in ASP.NET Core

Hello friends, I hope you all are doing great. In today's tutorial, we are going to have a look at what are Middleware in ASP.NET Core. It's our 3rd tutorial in ASP.NET Core series. In order to understand the Middleware, we have to open the Startup.cs file present in Solution Explorer. In our previous lecture, we have discussed the Code in Startup.cs and I have told you thhat we will discuss the Configure method later, so now we have to understand that code first. So, first let's define middleware components and then have a look at that code:

Middleware in ASP.NET Core

  • Middleware in ASP.NET Core are simple software components used to control HTTP requests and handle both incoming requests as well as outgoing responses.
  • Each middleware is a separate object, has a specific role assigned to it and are placed one after another in the request processing pipeline, as shown in below figure:
  • The middleware components are used for different purposes i.e. Authentication, Logging in, Verification, File Upload ( .js, .css ) etc.
  • These middleware components operate in fix order from top to bottom, so the incoming request is first received by the 1st Middleware and after proper processing on the request, it is forwarded to the 2nd Middleware.
  • A middleware can also skip the request and without any processing, forward it to next middleware.
  • For a proper working cloud based web application, we have to add a lot of middleware components, which we will see in coming lectures.
  • There are many builtin middleware components available in ASP.NET Core as Nuget packages and we can also design custom middleware components in it.
  • So, now let's open the Startup.cs file and have a look at the Configure Method, as shown in below figure:
  • You can see in the above code that we have a Startup Class, which has two functions in it, which we have discussed in our previous tutorial.
  • So, now let's have a close look at the code in Configure Method, it currently has three middleware components in it.
  • The first middleware components is placed inside IF loop and is shown in figure on right side.
  • You can see in the IF Loop we have Developer Exception Page, it's a builtin ASP.NET Core Middleware Component.
  • By convention, each middleware component start with "Use" word in ASP.NET Core, so if you are designing a custom middleware component, then its better to follow this practise.
  • We will study this Developer Exception Page in detail later, but for now you just need to know that its a middle ware component which shows an exception page to the developer and as it's inside IF Loop so it will be available only in Developers Environment, we will study Environment in coming lectures.
  • One more thing, we are using app and then dot operator to use Middleware in ASP.NET Core.
  • Second Middleware Component is app.UseRouting(), so the middleware name is Routing.
  • Finally the third middleware is End Points, which is displaying Hello World! on the page.
  • These Middlewares in the Configure Method, collectively create a pipeline structure i.e. there are executing one after another from top to bottom, this pipeline structure is called Request Processing Pipeline.
So, that was all about Middleware in ASP.NET Core. If you got into any trouble, then ask in comments and I will help you out. In the next article, we will have a look at How to add static files in ASP.NET Core. Till then take care & have fun !!!

How To Calculate Liquidated Damages in Construction?

Hello everyone, I hope you all are doing great. Today, I am going to share with you about "How To Calculate Liquidated Damages in Construction?" In almost all construction contracts that will be a clause that provides that the contractor will pay liquidated damages to the owner of the project in case there is a breach of contract. In construction, a breach of contract, which leads to the owner claiming liquidated damages, usually relates to a failure to complete a project in contractual time (that is, failing to complete works and handing over the house to the client at the date agreed on the contract). When calculating liquidated damages, the client bases them on a daily or weekly rate – the amount a contractor is required to pay will depend on the value of the property they are constructing. However, the client cannot use liquidated damages as a penalty, and that is why they need to learn how to calculate liquidated damages. In short, they have predetermined damages set when the contractor and owner are entering into a contract. The damages are based on actual losses the client is likely to incur in the unlikely event that the contractor does not complete a project on time. Some of the losses the client might incur have to do with:
  • Rent on temporary accommodation
  • Extra running costs
  • Removal costs
While the damages are based on a weekly or daily rate, the formulae might be more complicated in cases where there is partial possession or where the works are phased. After liquidated damages calculation, the client needs to document the method of calculation in case they ever need proof of calculations in court.

Importance of Calculating Liquidated Damages

It is essential for every owner to learn how to calculate liquidated damages in construction. For liquidated damages to be enforceable in court, the court requires that they are a reasonable amount. If the amount looks exorbitant or if the wrong liquidated damages calculation formula was used, the court will not enforce liquidated damages. Again, the damages are not penalties or punishment to the contractor – that is why the right liquidated damages formula has to be applied.  In instances where a contract prevents the client from claiming liquidated damages, or where the actual losses have a huge difference from the estimated liquidated losses, the client might claim for unliquidated (actual) damages through the court. Unliquidated damages are actual damages, whose amount is not pre-agreed and is determined by the courts.  A genuine liquidated damages calculation is needed to show that the damages are not penalties. In cases where the courts feel that calculating liquidated damages was done to punish the contractor, the claim will be dismissed.  Calculations will include:
  • Storage costs
  • Fees
  • Loss of rent
  • Loss of income
  • Finance costs
  • Rentals costs
  • Fees and fines from third parties
The link between the foreseen losses and the breach of contract has to be established – otherwise, a remote link between the damages and the breach of contract will not work. You can learn more about liquidated damages from this article.

How Liquidated Damages Calculation Works 

  • When learning how to calculate liquidated damages, the most crucial factor is time. When writing the contract for a construction project, the contractor and the client have to negotiate the duration it will take until completion of the project. In this case, the project is not completed on time; the owner stands to lose opportunities and money.
  • Besides the client, contractors will also lose money if a project extends past the contractual date – they will need to pay workers for longer than they anticipated. As such, both the client and the contractor have a reason to complete a project on time. 
  • In essence, the owner will try to ensure that contractors take all the risks associated with a project that is not completed on time. For them to transfer their risk to the contractor, they have to include a clause on the contract that lets them claim liquidated damages. The client, thus, has to know how to calculate liquidated damages in construction.
  • The liquidated damages clause will define the damages, and when the clause is activated, the client will deduct money from what they owe the contractor. The money will be withdrawn until the project is complete.
  • It is therefore crucial that when calculating liquidated damages, the client only includes what they will be able to recover in case the construction project is not completed on time. For the liquidated damages clause to be included in the contract, the contractor and the client have to agree on a reasonable amount.
  • Most public agencies will always have a liquidated damages clause in their contracts. The contract will be forced to pay a fixed amount for every day they do not complete a project. These damages will make sure that the contractor follows the project schedule as outlined in the contract.
  • Public agencies will use the clause to ensure that the contractor compensates them for any damages or losses they incur when a project is delayed.
  • However, the liquidated damages calculation formula has to show good faith – otherwise, it will be viewed as malicious punishment to the contractor by the client.
  • There is no standard liquidated damages formula seeing as different situations are different. As a client, you will estimate the damages you are likely to incur based on your special situation. For instance, a client who is building a residential house to settle their family might calculate the losses as rent they will have to pay for all the days the client will delay the project.
  • In another case, a client who is building residential houses to rent out might calculate damages based on the rent they will miss.

Conclusion

Once you have learned how to calculate liquidated damages (which involves figuring out the best-liquidated damages calculation formula for your situation), you will be good to go. However, even after using the right liquidated damages formula, if the actual damages significantly exceed the estimated losses, you need to claim for unliquidated damages after the project. For contractors, of the project delay was not your fault (say a natural disaster resulted in the delay), you can request an extension that does not involve you paying for liquidated damages. If you have a question regarding this post feel free to comment below. We are looking forward to hearing from you.
Syed Zain Nasir

I am Syed Zain Nasir, the founder of <a href=https://www.TheEngineeringProjects.com/>The Engineering Projects</a> (TEP). I am a programmer since 2009 before that I just search things, make small projects and now I am sharing my knowledge through this platform.I also work as a freelancer and did many projects related to programming and electrical circuitry. <a href=https://plus.google.com/+SyedZainNasir/>My Google Profile+</a>

Share
Published by
Syed Zain Nasir