Question

So we have a very large ASP.NET WebForms applications (Recently updated to .NET 4.0), and I want to attempt to put MVC in alongside it.

I've read lots of articles around the fact that the 2 types of applications do sit well beside each other. However, the current site makes heavy use of Spring.NET.

Ideally, all I want to do is start adding MVC pages to it, utilising the existing configuration of the business logic.

I've tried just using the MvcContextHandler, however, this leads to errors (The virtual path '/currentcontext.dummy' maps to another application, which is not allowed.) so I'm thinking that it's not as easy as that.

The reason I want to utilise the existing objects is that these will contain context information about the user, and what they've previously selected in the flow, so utilising the existing class that have been instantiated would be very useful.

So does anyone know if this is possible, and if so, are there any resources around to show how to do it?

I'm currently thinking that chaining IoC containers might be an option, so resolving controllers using Ninject, so the parameters are mapped to get the dependencies from the Spring container, but that seems like a long way around...

Was it helpful?

Solution

We upgraded a medium LOB-app to MVC3/Spring.Net and retained the analytics part written in Asp.Net WebForms (Telerik controls, reporting services), so it is possible.

Imho I did not use the MVC3 support facilities brought with Spring.Net and instead wrote a new one. At that time MVC3 was quite new the documentation that ultimately helped was:

http://bradwilson.typepad.com/blog/2010/10/service-location-pt5-idependencyresolver.html

According to Brad, to implement a dependency resolver for MVC, you will need to implement this interface:

public interface IDependencyResolver {
  object GetService(Type serviceType);
  IEnumerable<object> GetServices(Type serviceType);
}

http://msdn.microsoft.com/en-us/library/system.web.mvc.idependencyresolver.aspx

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top