I follow the Hangfire.io manual: http://docs.hangfire.io/en/latest/tutorials/send-email.html
However, when I copy and paste the provided code ~ / Views / Emails / NewComment.cshtml:
@model Hangfire.Mailer.Models.NewCommentEmail To: @Model.To From: mailer@example.com Subject: New comment posted Hello, There is a new comment from @Model.UserName: @Model.Comment <3
I encountered the following error:
Error 2 The type or namespace name 'Hangfire' could not be found (are you missing a using directive or an assembly reference?) Error 3 The name 'Model' does not exist in the current context
Models / NewCommentEmail.cs:
using System; using System.Collections.Generic; using System.Linq; using System.Web; using Postal; namespace HangFire.Mailer.Models { public class NewCommentEmail : Email { public string To { get; set; } public string UserName { get; set; } public string Comment { get; set; } } }
It seems when I create almost any other kind of Views: in Views / Email: "MVC 5 (Razor), MVC 5 View Page Layout (Razor) ... View page," all elements preceded by "@" are displayed on the page, which cannot be found in the current context. The name of the Soln project is "Hangfire.Mailer".
source share