0

Is it possible to dive deep into objects stored in the ViewBag when using SSVE?

I have a "User" object placed on the ViewBag as such:

context.ViewBag.User = new { UserName = userByCookie.UserName };

When I try to access the UserName property from SSVE as such:

@Context.ViewBag.User.UserName

I get the error message:

model must be a standard type or implement IDictionary Parameter name: model

However; I when I access the "User" in SSVE as such:

@Context.ViewBag.User

I end up with the following output in my SSVE view:

{ UserName = Eric }

Can I access the sub-properties of a viewbag object when using SSVE?

detroitpro
  • 3,853
  • 4
  • 35
  • 64

1 Answers1

1

Phillip Haydon, ‏@philliphaydon, answered this question via Twitter:

Sorry, it doesn't support depth. :(

https://twitter.com/philliphaydon/status/442842950431539200

detroitpro
  • 3,853
  • 4
  • 35
  • 64
  • NancyFx view engine rendering of any type (razor, spark, SSVE, etc) does not support any depth for ViewBag contents. – detroitpro Mar 12 '14 at 01:02
  • Assuming ViewBag.Page is an instance of PageModel, @ViewBag.Page.Foo.Bar seems to blow up in Nancy Razor, but @((PageModel)ViewBag.Page).Foo.Bar seems to work fine. – DanB Apr 08 '14 at 08:38