Build the future of communications.
Start Building for Free

Razor posts

  • By Dave Glick
    Render Emails Using Razor Templating Render Emails Using Razor Templating

    In the previous post, you went inside the Razor engine to learn how it works and understand what goes on when you turn a Razor file into HTML. You examined the four phases of parsing, code generation, compilation, and execution and how your C# code ends up being mixed together with your raw markup and output content. In this post, you’ll take things a step further and put that knowledge to use by comparing some open-source implementations of the Razor engine. You'll also learn how to use these Razor engines in your applications and render email templates to send emails with a service like SendGrid.

    The Different Kinds Of Razor Implementations

    Recall from the previous post that when you talk about Razor as a templating language, and even as an engine, you’re really talking about two different things: the underlying low-level Razor engine that’s responsible for the four execution …

    Read More
  • By Dave Glick
    What is Razor Templating, really? What is Razor Templating, really?

    Many .NET developers are familiar with Razor syntax. It's found in ASP.NET Core views (.cshtml), Razor pages, Razor component files (.razor), Blazor, Razor class libraries, and more. In general, Razor provides features for evaluating .NET code such as C# inside HTML. Despite being deceptively simple with only a handful of syntax primitives, there's a lot going on behind the scenes to make everything work correctly. In this post, you'll explore the fundamentals of the Razor engine. Then you’ll learn how it processes your Razor syntax to produce .NET assemblies and runs those assemblies to create content. Then in a follow-up post, once you've got a good handle on the Razor engine, you'll look at some open-source tools that leverage the Razor engine in various ways beyond what ships in .NET Core and how you can leverage these libraries to create Razor templates …

    Read More
  • By Néstor Campos
    Use Razor Layouts in FluentEmail to reuse Headers and Footers Use Razor Layouts in FluentEmail to reuse Headers and Footers

    You can quickly and intuitively send emails using the FluentEmail library for .NET, but once you send many different emails in your project, you have to be able to organize your email templates in a good way to reuse content and enforce consistency in terms of format and design. Luckily, Razor Layouts can help you reuse parts of your templates like headers and footers.

    Prerequisites

    You will need the following for your development environment:

    You can find the source code of this tutorial in this GitHub repository.

    Set up an SMTP server

    To be able to send emails at scale, you'll need an email sending service like the SendGrid Email API, but for …

    Read More
  • Newer
    Older
    Sign up and start building
    Not ready yet? Talk to an expert.