Giter Site home page Giter Site logo

scottsauber / razorhtmlemails Goto Github PK

View Code? Open in Web Editor NEW
210.0 6.0 71.0 1.39 MB

Implementing HTML Emails with ASP.NET Core Razor

Home Page: https://scottsauber.com/2018/07/07/walkthrough-creating-an-html-email-template-with-razor-and-razor-class-libraries-and-rendering-it-from-a-net-standard-class-library/

License: MIT License

C# 34.11% CSS 4.32% JavaScript 0.93% HTML 60.65%
razor aspnetcore html-emails

razorhtmlemails's Introduction

razorhtmlemails's People

Contributors

marcusturewicz avatar scottsauber avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

razorhtmlemails's Issues

.net 6 core compatibility

Hi! I really love the idea to use Razor in console applications or services, but it requires couple updates to make it work with .net 6

// It's required by IOC
var diagnosticListener = new DiagnosticListener("Microsoft.AspNetCore");
services.AddSingleton(diagnosticListener);
services.AddSingleton<DiagnosticSource>(diagnosticListener);

// Here we need to register assembly to make razor find compiled views            
services.AddRazorPages()
  .AddApplicationPart(Assembly.GetExecutingAssembly())
  .AddRazorRuntimeCompilation();

// Now we need to add IWebHostEnvironment with custom implementation as default one is internal.
// Implementation is just bunch of properties without any additional logic.
var fileProvider = new PhysicalFileProvider(Directory.GetCurrentDirectory());
services.AddSingleton<Microsoft.AspNetCore.Hosting.IWebHostEnvironment>(new HostingEnvironment
            {
                ApplicationName = Assembly.GetEntryAssembly().GetName().Name,
                WebRootFileProvider = fileProvider,
                ContentRootFileProvider = fileProvider
            });

Hoped this works from a Console project as well. But doesn't.

This works perfectly when that class library is finally being used in a asp mvc project. But say I have an executable which is used in a schedule job that periodically checks some thing in database and sends out emails.. This is not working.
DI is throwing lot of errors as it is not able to load some dependencies which are only available in Http Context.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.