protected override IHttpHandler GetHttpHandler(RequestContext requestContext) { var culture = requestContext.RouteData.Values["culture"] as string; if (culture == null) { throw new InvalidOperationException("URL parameter 'culture' is required"); } try { var ci = new CultureInfo(culture); Thread.CurrentThread.CurrentUICulture = ci; Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(ci.Name); // If route's culture is different from cookie's, update cookie var cookieLocale = requestContext.HttpContext.Request.Cookies["locale"]; if (cookieLocale == null || cookieLocale.Value != culture) { // Save route's culture to cookie requestContext.HttpContext.Response.Cookies.Add(new HttpCookie("locale", culture)); } } catch (CultureNotFoundException) { throw new InvalidOperationException("URL parameter 'culture' is invalid"); } return base.GetHttpHandler(requestContext); }
/// <summary> /// Creates the specified controller by using the specified request context. /// </summary> /// <param name="requestContext">The context of the HTTP request, which includes the HTTP context and route data.</param> /// <param name="controllerName">The name of the controller.</param> /// <returns>The controller.</returns> /// <exception cref="T:System.ArgumentNullException">The <paramref name="requestContext"/> parameter is null.</exception> /// /// <exception cref="T:System.ArgumentException">The <paramref name="controllerName"/> parameter is null or empty.</exception> /// <remarks></remarks> public override IController CreateController(RequestContext requestContext, string controllerName) { var factory = _slaveFactories.Factories.FirstOrDefault(x => x.CanHandle(requestContext)); return factory != null ? factory.CreateController(requestContext, controllerName) : base.CreateController(requestContext, controllerName); }
public IHttpHandler GetHttpHandler(RequestContext requestContext) { if (_httpHandler == null) _httpHandler = new ApplicationRouteHttpHandler(_url, _assembly); return _httpHandler; }
protected void Application_Error(object sender, EventArgs e) { Server.ClearError(); var routeData = new RouteData(); routeData.Values["controller"] = "Error"; HttpStatusCodeResult b = new HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest); if ((Context.Server.GetLastError() is HttpException) && ((Context.Server.GetLastError() as HttpException).GetHttpCode() != 404)) { Response.ContentType = "text/html"; routeData.Values["action"] = "Index"; } else { // Handle 404 error and response code Response.ContentType = "text/html"; Response.StatusCode = 404; routeData.Values["action"] = "Error"; } Response.TrySkipIisCustomErrors = true; // If you are using IIS7, have this line IController errorsController = new ErrorController(); HttpContextWrapper wrapper = new HttpContextWrapper(Context); var rc = new System.Web.Routing.RequestContext(wrapper, routeData); errorsController.Execute(rc); }
public override VirtualPathData GetVirtualPath(RequestContext requestContext, RouteValueDictionary values) { var internalRoute = MyRoute; if (internalRoute != null && !internalRoute.Url.Contains("{")) { return null; } var vpd = base.GetVirtualPath(requestContext, values); if (vpd != null) { var virtualPath = vpd.VirtualPath; if (RequireLowerCase) { virtualPath = virtualPath.ToLowerInvariant(); } if (AppendTrailingSlash) { var queryIndex = virtualPath.IndexOf('?'); string queryPart = string.Empty; if (queryIndex > -1) { queryPart = virtualPath.Substring(queryIndex); virtualPath = virtualPath.Substring(0, queryIndex); } if (!virtualPath.EndsWith("/")) { virtualPath = virtualPath + "/"; } virtualPath += queryPart; } vpd.VirtualPath = virtualPath; } return vpd; }
public override VirtualPathData GetVirtualPath(RequestContext requestContext, RouteValueDictionary values) { VirtualPathData path = base.GetVirtualPath(requestContext, values); if (path != null) { string virtualPath = path.VirtualPath; var lastIndexOf = virtualPath.LastIndexOf("?"); if (lastIndexOf != 0) { if (lastIndexOf > 0) { string leftPart = virtualPath.Substring(0, lastIndexOf).ToLowerInvariant(); string queryPart = virtualPath.Substring(lastIndexOf); path.VirtualPath = leftPart + queryPart; } else { path.VirtualPath = path.VirtualPath.ToLowerInvariant(); } } } return path; }
protected override void Initialize(RequestContext requestContext) { if (FormsService == null) { FormsService = new FormsAuthenticationService(); } if (MembershipService == null) { MembershipService = new AccountMembershipService(); } base.Initialize(requestContext); }
public void Execute(RequestContext requestContext) { var urlType = requestContext.UrlStrongTypeFromRoute(); using (log4net.NDC.Push(urlType.FullName)) { var steps = StepsFor(requestContext, urlType); var stepContext = new StepContext(requestContext, urlType); if (!steps.Any()) { HandleNoSteps(stepContext); return; } var lastContinuation = Continuation.Continue; foreach (var step in steps) { _log.Info("Step: " + step); lastContinuation = _stepInvoker.Invoke(step, stepContext); if (lastContinuation != Continuation.Continue) { break; } } if (lastContinuation == Continuation.Continue) { HandleNoEndingStep(stepContext); return; } _log.Info("Completed"); } }
protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType) { if (controllerType == null) return base.GetControllerInstance(requestContext, null); var controller = ObjectFactory.GetInstance(controllerType); return (IController)controller; }
public EmailSendAttempt SendWelcome(RequestContext request, User u) { var template = LoadTemplate( "template-user-welcome", request.HttpContext.Server.MapPath("~/Messages/UserWelcome.template") ); var url = new UrlHelper(request).Action(MVC.Public.Login.Index()); var e = Builder.Transform( template, new TemplateData { {"login", u.Login}, {"program", Application.ProgramName}, {"url", url.ToAbsoluteUrl(request.HttpContext.Request).ToString() }, }, request.HttpContext.Request ); e.Recipient = new EmailAddress { Address = u.Email, Name = u.DisplayName }; var attempt = Sender.Send(e); if (attempt.Success) { u.LastWeclomeEmailSent = DateTime.UtcNow; UserRepository.Save(u); } return attempt; }
public virtual LayoutModel CreateLayoutModel(ContentReference currentContentLink, RequestContext requestContext) { var startPageContentLink = SiteDefinition.Current.StartPage; // Use the content link with version information when editing the startpage, // otherwise the published version will be used when rendering the props below. if (currentContentLink.CompareToIgnoreWorkID(startPageContentLink)) { startPageContentLink = currentContentLink; } var startPage = _contentLoader.Get<StartPage>(startPageContentLink); return new LayoutModel { Logotype = startPage.SiteLogotype, LogotypeLinkUrl = new MvcHtmlString(_urlResolver.GetUrl(SiteDefinition.Current.StartPage)), ProductPages = startPage.ProductPageLinks, CompanyInformationPages = startPage.CompanyInformationPageLinks, NewsPages = startPage.NewsPageLinks, CustomerZonePages = startPage.CustomerZonePageLinks, LoggedIn = requestContext.HttpContext.User.Identity.IsAuthenticated, LoginUrl = new MvcHtmlString(GetLoginUrl(currentContentLink)), SearchActionUrl = new MvcHtmlString(EPiServer.Web.Routing.UrlResolver.Current.GetUrl(startPage.SearchPageLink)) }; }
public override IHttpHandler GetHttpHandler(RequestContext requestContext) { requestContext.HttpContext.Items["oauth_token"] = requestContext.HttpContext.Request["oauth_token"]; requestContext.HttpContext.Items["oauth_verifier"] = requestContext.HttpContext.Request["oauth_verifier"]; int tab = Convert.ToInt32(requestContext.RouteData.Values["t"]); return GetDnnHttpHandler(requestContext, ContactsRouteHandler.PortalId, tab, new string[] { "u", "s" }); }
/// <summary> /// ''' Cria uma rota do controller /// ''' </summary> /// ''' <remarks>Desenvolvido por Michel Oliveira @ Prime Team Tecnologia</remarks> public override IController CreateController(System.Web.Routing.RequestContext requestContext, string controllerName) { var actionValue = requestContext.RouteData.Values["action"].ToString(); requestContext.RouteData.Values["action"] = "Index"; // if (controllerName.ToUpper() == "login".ToUpper()) { using (LoginFactoryController controller = new LoginFactoryController()) { return(controller); } } else { using (PaginasController controller = new PaginasController()) { controller.Controller = controllerName; controller.Action = actionValue; return(controller); } } // requestContext.RouteData.Values["action"] = actionValue; return(new DefaultControllerFactory().CreateController(requestContext, controllerName)); }
protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType) { if (controllerType == null) throw new HttpException(404, string.Format("The controller for path '{0}' could not be found.", requestContext.HttpContext.Request.Path)); return (IController)kernel.Resolve(controllerType); }
/// <inheritdoc /> protected override bool TryMatchUrl(string[] urlParams, RequestContext requestContext) { var selfRouting = this.Controller as IRouteMapper; if (urlParams != null && selfRouting != null && selfRouting.TryMapRouteParameters(urlParams, requestContext)) { RouteHelper.SetUrlParametersResolved(true); return true; } var controllerName = requestContext.RouteData.Values[FeatherActionInvoker.ControllerNameKey] as string; string actionName = null; if (requestContext.RouteData.Values.ContainsKey("action")) { actionName = requestContext.RouteData.Values["action"] as string; requestContext.RouteData.Values.Remove("action"); } try { requestContext.RouteData.Values.Remove(FeatherActionInvoker.ControllerNameKey); MvcRequestContextBuilder.SetRouteParameters(urlParams, requestContext, this.Controller as Controller, controllerName); } finally { if (actionName != null) { requestContext.RouteData.Values["action"] = actionName; } } return true; }
protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType) { IController controller; if (controllerType == null) { throw new HttpException( 404, String.Format( "The controller for path '{0}' could not be found" + "or it does not implement IController.", requestContext.HttpContext.Request.Path)); } if (!typeof(IController).IsAssignableFrom(controllerType)) { throw new ArgumentException( string.Format( "Type requested is not a controller: {0}", controllerType.Name), "controllerType"); } try { controller = _container.Resolve(controllerType) as IController; } catch (Exception ex) { throw new InvalidOperationException(String.Format( "Error resolving controller {0}", controllerType.Name), ex); } return controller; }
/// <summary> /// Provides the object that processes the request. /// </summary> /// <param name="requestContext">An object that encapsulates information about the request.</param> /// <returns>An object that processes the request.</returns> public override IHttpHandler GetHttpHandler(RequestContext requestContext) { var handler = base.GetHttpHandler(requestContext); new PageInitializer().Initialize(handler); return handler; }
public static string Generate(RequestContext requestContext, NavigationRequest navigationItem, RouteValueDictionary routeValues) { if (requestContext == null) throw new ArgumentNullException("requestContext"); if (navigationItem == null) throw new ArgumentNullException("navigationItem"); var urlHelper = new UrlHelper(requestContext); string generatedUrl = null; if (!string.IsNullOrEmpty(navigationItem.RouteName)) { generatedUrl = urlHelper.RouteUrl(navigationItem.RouteName, routeValues); } else if (!string.IsNullOrEmpty(navigationItem.ControllerName) && !string.IsNullOrEmpty(navigationItem.ActionName)) { generatedUrl = urlHelper.Action(navigationItem.ActionName, navigationItem.ControllerName, routeValues, null, null); } else if (!string.IsNullOrEmpty(navigationItem.Url)) { generatedUrl = navigationItem.Url.StartsWith("~/", StringComparison.Ordinal) ? urlHelper.Content(navigationItem.Url) : navigationItem.Url; } else if (routeValues.Any()) { generatedUrl = urlHelper.RouteUrl(routeValues); } return generatedUrl; }
protected override void Initialize(RequestContext requestContext) { string cultureName = null; var request = requestContext.HttpContext.Request; // Attempt to read the culture cookie from Request var cultureCookie = request.Cookies["_culture"]; if (cultureCookie != null) cultureName = cultureCookie.Value; else if (request.UserLanguages != null) cultureName = request.UserLanguages[0]; if (Localization != null) { // Validate culture name cultureName = Localization.GetImplementedCulture(cultureName); // This is safe } if (!string.IsNullOrWhiteSpace(cultureName)) { Thread.CurrentThread.CurrentCulture = new CultureInfo(cultureName); Thread.CurrentThread.CurrentUICulture = new CultureInfo(cultureName); } base.Initialize(requestContext); }
/// <summary> /// Initialize controller /// </summary> /// <param name="requestContext">Request context</param> protected override void Initialize(System.Web.Routing.RequestContext requestContext) { //set work context to admin mode //if (Session["NhaXeId"]!=null) //EngineContext.Current.Resolve<IWorkContext>().NhaXeId = Convert.ToInt32(Session["NhaXeId"]); base.Initialize(requestContext); }
protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType) { if (controllerType != null && _container.Kernel.HasComponent(controllerType)) return (IController)_container.Resolve(controllerType); return base.GetControllerInstance(requestContext, controllerType); }
public IController CreateController( RequestContext requestContext, string controllerName) { // Was the requested controller registered? If so we'll return it if (_container.IsRegistered<IController>(controllerName.ToLowerInvariant())) return _container.Resolve<IController>(controllerName.ToLowerInvariant()); // If not being handled by a registered controller then use default controller var controller = _defaultControllerFactory.CreateController(requestContext, controllerName); // If controller implements IBuildUp then propagate dependency injection by // using the IBuildup interface to build up controller using Unity if (controller is IBuildUp) { // Provide opportunity to initialize/register types ((IBuildUp)controller).RegisterTypes(_container); // Buildup controller ((IBuildUp)controller).BuildUp(_container); // Hook for developer to use after all dependencies are resolved ((IBuildUp)controller).Initialize(); } return controller; }
private static IHttpHandler GetRedirectHandlerWithDefaults(RequestContext requestContext) { var routeValues = requestContext.RouteData.Values; routeValues["culture"] = LocaleHelper.DefaultCulture; SetLocaleCookie(requestContext, LocaleHelper.DefaultCulture); return new RedirectHandler(new UrlHelper(requestContext).RouteUrl(routeValues)); }
private void SetUpRequestContext() { HttpTest.SetUpHttpContext(); requestContext = new RequestContext(); requestContext.HttpContext = new HttpContextWrapper(HttpContext.Current); requestContext.RouteData = new RouteData(); }
public override IController CreateController(System.Web.Routing.RequestContext requestContext, string controllerName) { var parameters = requestContext.HttpContext.Request.Params; var encryptedParamKeys = parameters.AllKeys.Where(x => x.StartsWith(_settings.EncryptionPrefix)).ToList(); IRijndaelStringEncrypter decrypter = null; foreach (var key in encryptedParamKeys) { if (decrypter == null) { decrypter = GetDecrypter(requestContext); } var oldKey = key.Replace(_settings.EncryptionPrefix, string.Empty); var oldValue = decrypter.Decrypt(parameters[key]); if (requestContext.RouteData.Values[oldKey] != null) { if (requestContext.RouteData.Values[oldKey].ToString() != oldValue) { throw new ApplicationException("Form values is modified!"); } } requestContext.RouteData.Values[oldKey] = oldValue; } if (decrypter != null) { decrypter.Dispose(); } return(base.CreateController(requestContext, controllerName)); }
string RenderEvents(UserEventSubscription s, IQueryable <AuditEventView> events) { using (var writer = new StringWriter()) { var rc = new System.Web.Routing.RequestContext(HttpContext, new RouteData()); var cc = new ControllerContext(rc, Reports); var view = ViewEngines.Engines.OfType <CompiledViewEngine>().First().FindView(cc, typeof(Views.Notifications.EmailNotification).AssemblyQualifiedName, "", true); try { var model = new Models.EmailNotificationModel { User = s.User, Events = AuditUI.Visualize(AuditUIScope.Email, events) .GroupBy(e => e, GroupingEventsComparer.Instance) .Select(es => es.First()) }; view.View.Render(new ViewContext(cc, view.View, new ViewDataDictionary(model), new TempDataDictionary(), writer), writer); } finally { view.ViewEngine.ReleaseView(cc, view.View); } return(writer.ToString()); } }
protected override IController GetControllerInstance(RequestContext context, Type controllerType) { if (controllerType == null) { throw new HttpException(404, string.Format("The controller for path '{0}' could not be found or it does not implement IController.", context.HttpContext.Request.Path)); } return (IController) container.GetService(controllerType); }
protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType) { return controllerType == null ? null : (IController)ninjectKernel.Get(controllerType); }
/// <summary> /// Gets controller instance /// </summary> /// <param name="requestContext">request context </param> /// <param name="controllerType">controloler that has been requested</param> /// <returns>IController</returns> protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType) { if (controllerType == null) return base.GetControllerInstance(requestContext, controllerType); return DiContainer.Resolve<IController>(controllerType.FullName); }
protected override IController GetControllerInstance(System.Web.Routing.RequestContext requestContext, Type controllerType) { ICommandBus bus = new CommandBus(); IController controller = Activator.CreateInstance(controllerType, bus) as BaseController; return(controller); }
/// <summary>Retrieves the controller instance for the specified request context and controller type.</summary> /// /// <param name="requestContext">The context of the HTTP request, which includes the HTTP context and route data.</param> /// <param name="controllerType">The type of the controller.</param> /// /// <returns>The controller instance.</returns> protected override IController GetControllerInstance( RequestContext requestContext, Type controllerType) { try { if (controllerType == null) return base.GetControllerInstance(requestContext, null); var controller = funqBuilder.CreateInstance(controllerType) as IController; return controller ?? base.GetControllerInstance(requestContext, controllerType); } catch (HttpException ex) { if (ex.GetHttpCode() == 404) { try { if (NServiceKitController.CatchAllController != null) { return NServiceKitController.CatchAllController(requestContext); } } catch { } //ignore not found CatchAllController } throw; } }
private ControllerContext ControllerContextFactory(RequestContext requestContext, string controllerName, string areaName) { try { IController controller = ControllerBuilder.Current.GetControllerFactory().CreateController(requestContext, controllerName); if (controller == null) { return null; } if (areaName.HasValue() && !controller.GetType().FullName.Contains("Areas")) { IList<Type> controllerTypes = controllerTypeCache.GetControllerTypes(controllerName) ?? new List<Type>(); Type controllerType = GetControllerByArea(controllerTypes, areaName); controller = (IController)Activator.CreateInstance(controllerType); } return new ControllerContext(requestContext, controller as ControllerBase); } catch (Exception) { return null; } }
/// <summary> /// Retrieves the controller type for the specified name and request context. /// </summary> /// /// <returns> /// The controller type. /// </returns> /// <param name="requestContext">The context of the HTTP request, which includes the HTTP context and route data.</param> /// <param name="controllerName">The name of the controller.</param> internal Type GetControllerTypeInternal(RequestContext requestContext, string controllerName) { var factory = _slaveFactories.Factories.FirstOrDefault(x => x.CanHandle(requestContext)); if (factory != null) { //check to see if the factory is of type UmbracoControllerFactory which exposes the GetControllerType method so we don't have to create // an instance of the controller to figure out what it is. This is a work around for not having a breaking change for: // http://issues.umbraco.org/issue/U4-1726 var umbFactory = factory as UmbracoControllerFactory; if (umbFactory != null) { return umbFactory.GetControllerType(requestContext, controllerName); } //we have no choice but to instantiate the controller var instance = factory.CreateController(requestContext, controllerName); if (instance != null) { return instance.GetType(); } return null; } return base.GetControllerType(requestContext, controllerName); }
private SiteMapNode AddNodeRecursive(XmlNode xmlNode, SiteMapNode parent, RequestContext context) { var routeValues = (from XmlNode attrib in xmlNode.Attributes where !reservedNames.Contains(attrib.Name.ToLower()) select new { attrib.Name, attrib.Value }).ToDictionary(x => x.Name, x => (object)x.Value); RouteValueDictionary routeDict = new RouteValueDictionary(routeValues); VirtualPathData virtualPathData = RouteTable.Routes.GetVirtualPath(context, routeDict); if (virtualPathData == null) { string message = "RoutingSiteMapProvider is unable to locate Route for " + "Controller: '" + routeDict["controller"] + "', Action: '" + routeDict["action"] + "'. " + "Make sure a route has been defined for this SiteMap Node."; throw new InvalidOperationException(message); } string url = virtualPathData.VirtualPath; string title = xmlNode.Attributes["title"].Value; SiteMapNode node = new SiteMapNode(this, Guid.NewGuid().ToString(), url, title); base.AddNode(node, parent); foreach (XmlNode childNode in xmlNode.ChildNodes) { AddNodeRecursive(childNode, node, context); } return node; }
protected override IController GetControllerInstance(RequestContext context, Type controllerType) { if (controllerType == null) return null; return ObjectFactory.GetInstance(controllerType) as Controller; }
protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (requestContext.RouteData.Values["lang"] != null && requestContext.RouteData.Values["lang"] as string != "null") { CurrentLangCode = requestContext.RouteData.Values["lang"] as string; switch (CurrentLangCode) { case "ua": CurrentLangCode = "uk-UA"; break; case "en": CurrentLangCode = "en-GB"; break; case "ru": CurrentLangCode = "ru-RU"; break; default: CurrentLangCode = "uk-UA"; break; } var ci = new CultureInfo(CurrentLangCode); Thread.CurrentThread.CurrentUICulture = ci; Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(ci.Name); } base.Initialize(requestContext); }
public void UsesSpecifiedBinder() { var controller = typeof(FromRouteAttr.SpecifiedBinderController); routes.Clear(); routes.MapCodeRoutes(controller); var httpContextMock = new Mock<HttpContextBase>(); httpContextMock.Setup(c => c.Request.AppRelativeCurrentExecutionFilePath).Returns("~/Foo/yes"); var httpResponseMock = new Mock<HttpResponseBase>(); httpContextMock.Setup(c => c.Response).Returns(httpResponseMock.Object); var routeData = routes.GetRouteData(httpContextMock.Object); var controllerInstance = (ControllerBase)Activator.CreateInstance(controller); controllerInstance.ValidateRequest = false; var requestContext = new RequestContext(httpContextMock.Object, routeData); var controllerContext = new ControllerContext(requestContext, controllerInstance); controllerInstance.ValueProvider = new ValueProviderCollection(new IValueProvider[] { new RouteDataValueProvider(controllerContext) }); ((IController)controllerInstance).Execute(requestContext); httpResponseMock.Verify(c => c.Write(It.Is<string>(s => s == "True")), Times.AtLeastOnce()); }
protected override System.Web.IHttpHandler GetHttpHandler(System.Web.Routing.RequestContext requestContext) { var urlLocale = requestContext.RouteData.Values["culture"] as string; var cultureName = urlLocale ?? ""; var cookieLocale = requestContext.HttpContext.Request.Cookies["locale"]; if (cookieLocale != null) { // if request contains locale cookie, we need to put higher priority than url locale // user might click the link from somewhere but he/she already set different locale if (!cookieLocale.Value.Equals(urlLocale, StringComparison.OrdinalIgnoreCase)) { // if cookie locale and url cookie are different, // we should redirect with cookie locale var routeValues = requestContext.RouteData.Values; routeValues["culture"] = cookieLocale.Value; var queryString = requestContext.HttpContext.Request.QueryString; foreach (var key in queryString.AllKeys) { if (!routeValues.ContainsKey(key)) { routeValues.Add(key, queryString[key]); } } return(new RedirectHandler(new UrlHelper(requestContext).RouteUrl(routeValues))); } else { cultureName = cookieLocale.Value; } } if (cultureName == "") { return(GetDefaultLocaleRedirectHandler(requestContext)); } try { var culture = CultureInfo.GetCultureInfo(cultureName); Thread.CurrentThread.CurrentCulture = culture; Thread.CurrentThread.CurrentUICulture = culture; } catch (CultureNotFoundException) { // if CultureInfo.GetCultureInfo throws exception // we should redirect with default locale return(GetDefaultLocaleRedirectHandler(requestContext)); } if (cookieLocale == null) { requestContext.HttpContext.Response.AppendCookie(new HttpCookie("locale", cultureName)); } return(base.GetHttpHandler(requestContext)); }
protected override void Initialize(System.Web.Routing.RequestContext requestContext) { //GetUserProfile(requestContext); base.Initialize(requestContext); //UID = requestContext.HttpContext.Request.Cookies["ticket_hhtravel"] != null ? requestContext.HttpContext.Request.Cookies["ticket_hhtravel"].Value : string.Empty; }
protected override void Initialize(System.Web.Routing.RequestContext requestContext) { base.Initialize(requestContext); if (OTSession.OperationalClient != null) { _profileRepo = RepoGetter <UserProfileRepo> .Get(OTSession.LoginedUserName, OTSession.RealClient.Id, OTSession.OperationalClient.Id); } }
protected override bool AuthorizeCore(System.Web.Routing.RequestContext requestContext) { if (requestContext.GetRequestValue("Action").ToLower() == "largefile") { return(true); } return(base.AuthorizeCore(requestContext)); }
public virtual Type GetControllerType_(System.Web.Routing.RequestContext requestContext, string controllerName) { if (GetControllerTypeDelegate != null) { return(GetControllerTypeDelegate()); } return(base.GetControllerType(requestContext, controllerName)); }
protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (service == null) { service = new UserService(); } base.Initialize(requestContext); }
protected override void Initialize(System.Web.Routing.RequestContext requestContext) { base.Initialize(requestContext); var u = requestContext.HttpContext.User; var data = _usersContext.UserProfiles.FirstOrDefault(x => x.UserName == u.Identity.Name); ViewBag.UserData = data; }
public IEnumerable <System.Web.Mvc.SelectListItem> GetSelectListItems(System.Web.Routing.RequestContext requestContext, string filter = null) { var list = Kooboo.CMS.Common.Runtime.EngineContext.Current.Resolve <ABRuleSettingManager>().All(Site.Current, ""); return(list.Select(it => new SelectListItem() { Text = it.Name, Value = it.Name })); }
protected override IAsyncResult BeginExecute(System.Web.Routing.RequestContext requestContext, AsyncCallback callback, object state) { Context = requestContext; BaseUrl = requestContext.HttpContext.Request.Url.GetLeftPart(UriPartial.Authority) + requestContext.HttpContext.Request.ApplicationPath; var sessionCookie = Context.HttpContext.Request.Cookies["ss-pid"]; SessionID = sessionCookie != null ? sessionCookie.Value : ""; return(base.BeginExecute(requestContext, callback, state)); }
protected override IController GetControllerInstance(System.Web.Routing.RequestContext requestContext, System.Type controllerType) { if (controllerType == null) { return(null); } return(_container.Resolve(controllerType) as IController); }
protected override void Initialize(System.Web.Routing.RequestContext requestContext) { base.Initialize(requestContext); PrimaryUser = UsersCollection.PrimaryUsers().Where(u => u.IsPrimaryUser).FirstOrDefault(); if (PrimaryUser != null) { ViewBag.Brand = PrimaryUser.SiteName; } }
protected override void Initialize(System.Web.Routing.RequestContext requestContext) { base.Initialize(requestContext); var user = UsersCollection.PrimaryUser(); if (user != null) { ViewBag.Brand = user.SiteName; } }
protected override void Initialize(System.Web.Routing.RequestContext requestContext) { base.Initialize(requestContext); if (!Request.IsAjaxRequest()) { Session[currentTermSearchedKey] = ""; Session[currentPageSessionKey] = null; } }
protected override void Initialize(System.Web.Routing.RequestContext requestContext) { base.Initialize(requestContext); _db = LS.CurrentEntityContext; CultureInfo culture = new CultureInfo("he-IL"); culture.DateTimeFormat.ShortDatePattern = "dd/MM/yyyy"; System.Threading.Thread.CurrentThread.CurrentCulture = culture; System.Threading.Thread.CurrentThread.CurrentUICulture = culture; }
protected override void Initialize(System.Web.Routing.RequestContext requestContext) { base.Initialize(requestContext); /* * if (requestContext.HttpContext.Session["oRegional"] != null) * list_regional = (List<int>)Session["oRegional"]; * * * if (requestContext.HttpContext.Session["cd_empresa"] != null) * cd_empresa = requestContext.HttpContext.Session["cd_empresa"].ToString() == null ? 0 : Convert.ToInt32(requestContext.HttpContext.Session["cd_empresa"].ToString()); * if (requestContext.HttpContext.Session["cd_regional"] != null) * cd_regional = requestContext.HttpContext.Session["cd_regional"].ToString() == null ? 0 : Convert.ToInt32(requestContext.HttpContext.Session["cd_regional"].ToString()); * if (requestContext.HttpContext.Session["cd_gusuario"] != null) * cd_gusuario = requestContext.HttpContext.Session["cd_gusuario"].ToString() == null ? 0 : Convert.ToInt32(requestContext.HttpContext.Session["cd_gusuario"].ToString()); * if (requestContext.HttpContext.Session["str_empresa"] != null) * str_empresa = requestContext.HttpContext.Session["str_empresa"].ToString() == null ? "DEMO" : requestContext.HttpContext.Session["str_empresa"].ToString(); * if (requestContext.HttpContext.Session["usuario"] != null) * nome_usuario = requestContext.HttpContext.Session["usuario"].ToString() == null ? "" : requestContext.HttpContext.Session["usuario"].ToString(); * if (requestContext.HttpContext.Session["consolida"] != null) * consolida = requestContext.HttpContext.Session["consolida"].ToString() == null ? "E" : requestContext.HttpContext.Session["consolida"].ToString(); * * * * if (requestContext.HttpContext.Session["oEmpresa"] != null) * { * db = new b2yweb_entities(requestContext.HttpContext.Session["oEmpresa"].ToString()); * } * else * { * System.Web.Security.FormsAuthentication.SignOut(); * Session.Clear(); * } * * */ db = new b2yweb_entities("oracle"); _email = new SendEmail(); dt_atual_com_hora_sql = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); dt_atual_sem_hora_sql = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd")); cookie = HttpContext.Request.Cookies.Get("PortalProcedimento"); try { cd_usuario = Convert.ToInt16(cookie.Values["cd_usuario"].ToString()); } catch { System.Web.Security.FormsAuthentication.SignOut(); Session.Clear(); } }
public IController CreateController(System.Web.Routing.RequestContext requestContext, string controllerName) { try { return(_container.Resolve <IController>(controllerName)); } catch (Exception) { return(_factory.CreateController(requestContext, controllerName)); } }
public void Execute(System.Web.Routing.RequestContext requestContext) { using (var compositionContainer = new CompositionContainer(CompositionSettings.DefaultCatalog)) { // Compose inner controller: compositionContainer.ComposeParts(this.innerController); // Delegate execution to inner controller: this.innerController.Execute(requestContext); } }
protected override IHttpHandler GetHttpHandler(System.Web.Routing.RequestContext requestContext) { if (ModuleManager.IsActive(moduleId)) { return(base.GetHttpHandler(requestContext)); } else { //throw new Exception(string.Format("Module '{0}' is not active", moduleId)); return(new ModuleNotAvailableHandler(requestContext)); } }
public static void Initialize(System.Web.Routing.RequestContext requestContext) { if (requestContext.HttpContext.Session["LangSelectList"] != null) { string LangSelectList = requestContext.HttpContext.Session["LangSelectList"] as string; if (!string.IsNullOrEmpty(LangSelectList)) { System.Globalization.CultureInfo culture = new System.Globalization.CultureInfo(LangSelectList); System.Threading.Thread.CurrentThread.CurrentCulture = culture; System.Threading.Thread.CurrentThread.CurrentUICulture = culture; } } }
protected override void Initialize(System.Web.Routing.RequestContext requestContext) { base.Initialize(requestContext); if (!Settings.IsInstalled) { return; } var timeZoneOffset = SiteConfig.TimeOffset.ToInt(); ViewData[ViewDataKeys.TimeZoneOffset] = timeZoneOffset; }
/// <summary> /// 这个函数的调用顺序在:BaseController的构造函数和继承BaseController的构造函数调用之后才进行调用 /// </summary> /// <param name="requestContext"></param> protected override void Initialize(System.Web.Routing.RequestContext requestContext) { base.Initialize(requestContext); UserManager = HttpContext.GetOwinContext().GetUserManager <ApplicationUserManager>(); var user = UserManager.FindById(User.Identity.GetUserId()); //既没有通过系统登录,也没有通过外部登录,返回给APP一个结果,通知没有登录 if (user == null) { Rederect(requestContext, Url.Action("Login", "Account")); } }
protected override void Initialize(System.Web.Routing.RequestContext requestContext) { base.Initialize(requestContext); if (!requestContext.HttpContext.Request.IsAjaxRequest()) { if (LoginUser != null) { ViewBag.UserName = LoginUser.RealName; } this.Path = requestContext.HttpContext.Request.FilePath; Task.Run(() => SetMenu()).Wait(); } }