Apr 15, 2016 at 4:59 PM
Edited Apr 15, 2016 at 5:58 PM
I can't seem to pass a model from my controller to the view unless I use Viewbag. Does the plugin framework allow for this or am I just missing something?
When I try passing a model to the view I get a null reference exception in the Execute() method being run on the .cshtml file.
Here is an example:
[NullReferenceException: Object reference not set to an instance of an object.]
ASP._Page_Plugins_JNBOMvcPlugin_Views_JNBOCustom_EmailCoupon_cshtml.Execute() in c:\Users\chadlacroix\AppData\Local\Temp\Temporary ASP.NET Files\vs\b9d8e60a\26ee2beb\App_Web_views.jnbocustom.emailcoupon.cshtml.85647037.d4lpippg.0.cs:0
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +101
The workaround I have been using is creating a Viewbag.model and putting my model in it. Then I call my view from my controller without a model: return View("ExampleView")
To retrieve my model in the view I am casting it to my Type to get strongly typed again.
var localModel = (SampleApplication.Models.MyModel)ViewBag.Model;
I would like to remove this workaround if anyone could help me out.