Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.

Move MvcApplication to Microsoft.AspNet.Mvc assembly #128

Closed
davidfowl opened this issue Mar 22, 2014 · 2 comments
Closed

Move MvcApplication to Microsoft.AspNet.Mvc assembly #128

davidfowl opened this issue Mar 22, 2014 · 2 comments

Comments

@davidfowl
Copy link
Member

Move MvcApplication to the Microsoft.AspNet.Mvc assembly so that we can have a fallback for when the service provider isn't composed with MVC services. It'll make the following possible:

using Microsoft.AspNet.Abstractions;
using Microsoft.AspNet.Mvc;
using Microsoft.AspNet.Routing;

namespace MvcSample.Web
{
    public class Startup
    {
        public void Configuration(IBuilder app)
        {
            var routes = new RouteCollection()
            {
                DefaultHandler = new MvcApplication(app.ServiceProvider)
            };

            routes.MapRoute(
                "{controller}/{action}",
                new { controller = "Home", action = "Index" });

            routes.MapRoute(
                "{controller}",
                new { controller = "Home" });

            app.UseRouter(routes);
        }
    }
}

The code to fallback would look something like this:

public MvcApplication(IServiceProvider services)
{
    _services = services;
    // Look for some marker that indicates if Mvc has be configured 
    if (services.GetService<IActionSelector>() == null)
    {
        _services = MvcServices.GetDefaultServices()
                               .BuildServiceProvider(services);
    }
}

The check itself can change but we just need a way to figure out if the service provider is composed for mvc or not.

@yishaigalatzer
Copy link
Contributor

@davidfowl is this still relevant?

@davidfowl
Copy link
Member Author

Nope

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants