I am trying to use MvcMailer on a web api and i am stuck!!! I am getting the following error. I think it has something to do with the routing between usermailer and view. I seen it can't find the view, but i could be wrong. Any help would be appreciate.
Thanks
Error:
Value cannot be null.Parameter name: routeData
StackTrace:
at System.Web.Routing.RequestContext..ctor(HttpContextBase httpContext, RouteData routeData)
at System.Web.Mvc.ControllerContext..ctor(HttpContextBase httpContext, RouteData routeData, ControllerBase controller)
at Mvc.Mailer.MailerBase.CreateControllerContext()
at Mvc.Mailer.MailerBase.ViewExists(String viewName, String masterName)
at Mvc.Mailer.MailerBase.TextViewExists(String viewName, String masterName)
at Mvc.Mailer.MailerBase.PopulateBody(MailMessage mailMessage, String viewName, String masterName, Dictionary`2 linkedResources)
at Mvc.Mailer.MailerBase.Populate(Action`1 action)
at App.Api.Mailers.UserMailer.NewCandidate() in e:\VS2013 Projects\App.Api\Mailers\UserMailer.cs:line 15
at App.Api.Controllers.CandidatesController.Get() in e:\VS2013 Projects\App.Api\Controllers\CandidatesController.cs:line 31
controller:
private readonly UserMailer _mailer = new UserMailer();
[Authorize]
[Route("")]
[HttpPost]
// POST api/requests
public HttpResponseMessage Post(Candidate candidate)
{
_repository.CandidateRepository.Insert(candidate);
_repository.Save();
_mailer.NewCandidate().Send();
return Request.CreateResponse(HttpStatusCode.OK, candidate);
}
UserMailer Class:
public class UserMailer : MailerBase, IUserMailer
{
public UserMailer()
{
MasterName="_Layout";
}
public virtual MvcMailMessage NewCandidate()
{
//ViewBag.Data = someObject;
return Populate(x =>
{
x.Subject = "NewCandidate";
x.ViewName = "NewCandidate";
x.To.Add("test@test.test");
});
}
}
Folder Structure:
Thanks