MvcMailer icon indicating copy to clipboard operation
MvcMailer copied to clipboard

Rename default layout to MailerLayout or (ScaffoldName)Layout

Open nmolzach opened this issue 10 years ago • 2 comments

this issue was posting here:

https://github.com/smsohan/MvcMailer/issues/91

it really is strange, because 90% of my messages aren't effected, however, the one that was effected i just burned a day on trying to figure this out. I'd suggest you rename the default name of the layout that gets scaffolded to match the name of the mailer object.

nmolzach avatar Apr 04 '14 19:04 nmolzach

So, this is definitely a bug, and I really don't understand where it's happening, but I had one email where it would always try to pull the layout out of the viewstart. I tried everything -- setting it in the view, setting the mastername to null in the controller, and nothing seemed to work. This is what I ended up doing which works but it is a complete hack :)

in my _ViewStart.cshtml:

@{ Layout = "~/Views/Shared/_Layout.cshtml"; var child = this.ChildPage.ToString().ToLower(); here itif (child.Contains("usermailer")) { Layout = "~/Views/UserMailer/_MailerLayout.cshtml"; } }

works okay, but if you had multiple mailers that would obviously be a pain to maintain... any ideas on whats causing this? what's stranger is that i had 1 successful send of this email today before I implemented this fix.

nmolzach avatar Apr 10 '14 23:04 nmolzach

ya i guess that didnt work (another example of the inconsistency in this issue...), really weird, only one route is doing this... any ideas?

nmolzach avatar Apr 14 '14 20:04 nmolzach