R – Integrating ASP.NET-MVC with Silverlight using WCF and Ninject as IoC/DI

asp.net-mvcinversion-of-controlsilverlightwcf

I have a prototype ASP.NET-MVC website which uses Ninject as a IoC container. All service-classes and repository-classes used by MVC Controllers are properly injected by Ninject. This is great.

The next thing I need to add there is Silverlight (version 3 to be more precise).
Silverlight will be connecting to my server using WCF service, hosted in ASP compatibility mode, to the same ASP.NET-MVC website.

What Silverlight needs is to 'download'/'get' a kind of ViewModel using WCF (the better name would be Client-Side Model). This is also possible – I imported WCF service and setup all security-related xml configuration files.

Here is the stuff I want to know….

  1. Is that OK that model returned by WCF service is rather complex and includes arrays and inheritance (at array items' level)… or maybe there is another and better way to send it from server to client?

  2. At Server-Side for regular asp-mvc stuff all service-classes used by controllers are injected by Ninject. How to inject services for WCF-service classes?

  3. Do WCF service has an access to HttpContext.Current.Items? I need to grab from here logged User Id and a few profile-related data (regular forms auth. stuff).

EDIT

Ad 3. It's possible enabling AspNetCompatibilityRequirements

Has anybody ideas for point 2?

Best Answer

For the 1st Question.

  1. Yes it is okay to return a complex structure, provided you have explicitly applied the '[DataMember]' attribute to each and every needed property of the Object/s.
Related Topic