a575963da9
Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
33 lines
1.2 KiB
C#
33 lines
1.2 KiB
C#
namespace System.Web.Mvc {
|
|
using System.Web.Routing;
|
|
using System.Web.SessionState;
|
|
|
|
public class MvcRouteHandler : IRouteHandler {
|
|
private IControllerFactory _controllerFactory;
|
|
|
|
public MvcRouteHandler() {
|
|
}
|
|
|
|
public MvcRouteHandler(IControllerFactory controllerFactory) {
|
|
_controllerFactory = controllerFactory;
|
|
}
|
|
|
|
protected virtual IHttpHandler GetHttpHandler(RequestContext requestContext) {
|
|
requestContext.HttpContext.SetSessionStateBehavior(GetSessionStateBehavior(requestContext));
|
|
return new MvcHandler(requestContext);
|
|
}
|
|
|
|
protected virtual SessionStateBehavior GetSessionStateBehavior(RequestContext requestContext) {
|
|
string controllerName = (string)requestContext.RouteData.Values["controller"];
|
|
IControllerFactory controllerFactory = _controllerFactory ?? ControllerBuilder.Current.GetControllerFactory();
|
|
return controllerFactory.GetControllerSessionBehavior(requestContext, controllerName);
|
|
}
|
|
|
|
#region IRouteHandler Members
|
|
IHttpHandler IRouteHandler.GetHttpHandler(RequestContext requestContext) {
|
|
return GetHttpHandler(requestContext);
|
|
}
|
|
#endregion
|
|
}
|
|
}
|