smsohan / MvcMailer

A Mailer for ASP.Net MVC that forms the Email Body using MVC Views (Razor etc.) following Ruby on Rails ActionMailer style
MIT License
584 stars 178 forks source link

Since moving to MVC4: The view at '~/Views/[...]/Invitation.text.cshtml' must derive from WebViewPage, or WebViewPage<TModel>. #47

Closed AymericG closed 12 years ago

AymericG commented 12 years ago

I migrated to MVC4 and since then MVCMailer doesn't work.

Any idea on how I could fix this issue?

The view at '~/Views/[...]/Invitation.text.cshtml' must derive from WebViewPage, or WebViewPage.

I have tried to add:

@inherits System.Web.Mvc.WebViewPage

without success.

Eonasdan commented 12 years ago

Look at your web.config under the Views folder I add these entries that broke my mvc4 application

<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />

<pages validateRequest="false" pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
  <namespaces>
    <add namespace="Mvc.Mailer" />
  </namespaces>
</pages>

both of those entries already existed in my config file for version 4

AymericG commented 12 years ago

Thanks, I created a brand new MVC 4 project, and copy pasted the web.config in my project and added the entries specific to my project. This issue was a problem related to the migration to MVC4, not MvcMailer itself I believe.

Thanks!

sharique commented 12 years ago

@Eonasdan your web.config show MVC version 3 (System.Web.Mvc, Version=3.0.0.0) , you should change it to 4. I think this might fix the problem.

Eonasdan commented 12 years ago

@sharique the problem was that my MVC 4 application already had those entries for v4 but mvcmailer added the nodes again for v3. I fixed the problem by removing the duplicated nodes for v3