andrewdavey / postal

Email sending for asp.net mvc using the view engine system to render emails.
http://aboutcode.net/postal
MIT License
536 stars 168 forks source link

_ViewStart giving Nullreference exception with Multi Layouts. #137

Open shahil229 opened 8 years ago

shahil229 commented 8 years ago

Im getting this error because MVC Postal seems to be overriding my root _ViewStart. The program runs normal without it. Postal _ViewStart is still at its default.

Postal seems to have an issue when there is more than one layout specified. Unfortunately I need to have them.

 if (this.User.IsInRole("Admin") || !this.User.Identity.IsAuthenticated)
    {
        Layout = "~/Views/Shared/_AdminLayout.cshtml";
    }

    else if (this.User.IsInRole("Territorial Strategic Planning Coordinator") || this.User.IsInRole("Programme Secretary") || this.User.IsInRole("IT") || !this.User.Identity.IsAuthenticated)
    {
        Layout = "~/Views/Shared/_LayoutLevel1.cshtml";
    }`

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Is there any way to fix this? Thanks for any help.