当前位置: 首页>>代码示例>>C#>>正文


C# Routing.RequestContext类代码示例

本文整理汇总了C#中System.Web.Routing.RequestContext的典型用法代码示例。如果您正苦于以下问题:C# RequestContext类的具体用法?C# RequestContext怎么用?C# RequestContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RequestContext类属于System.Web.Routing命名空间,在下文中一共展示了RequestContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetControllerInstance

        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);
        }
开发者ID:devworker55,项目名称:SourceLab,代码行数:7,代码来源:WindsorControllerFactory.cs

示例2: SendWelcome

 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;
 }
开发者ID:nicknystrom,项目名称:AscendRewards,代码行数:27,代码来源:UserMessaging.cs

示例3: GetControllerInstance

        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);
        }
开发者ID:admgalloway,项目名称:adm.godo,代码行数:7,代码来源:WindsorControllerFactory.cs

示例4: Initialize

        protected override void Initialize(RequestContext requestContext)
        {
            if (FormsService == null) { FormsService = new FormsAuthenticationService(); }
            if (MembershipService == null) { MembershipService = new AccountMembershipService(); }

            base.Initialize(requestContext);
        }
开发者ID:cmcginn,项目名称:AIM,代码行数:7,代码来源:AccountController.cs

示例5: Execute

        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");
              }
        }
开发者ID:aaronjensen,项目名称:splits,代码行数:34,代码来源:SplitsController.cs

示例6: GetControllerInstance

        /// <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);
        }
开发者ID:AndyCC,项目名称:Jumbleblocks-website,代码行数:13,代码来源:WindsorControllerFactory.cs

示例7: GetVirtualPath

        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;
        }
开发者ID:yimogit,项目名称:YimoFramework,代码行数:26,代码来源:LowercaseRoute.cs

示例8: GetRedirectHandlerWithDefaults

 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));
 }
开发者ID:arzion,项目名称:TemplateProject,代码行数:7,代码来源:LocalizedRouteHandler.cs

示例9: SetUpRequestContext

 private void SetUpRequestContext()
 {
     HttpTest.SetUpHttpContext();
     requestContext = new RequestContext();
     requestContext.HttpContext = new HttpContextWrapper(HttpContext.Current);
     requestContext.RouteData = new RouteData();
 }
开发者ID:jarrettmeyer,项目名称:curiosity-common-mvc,代码行数:7,代码来源:LowercaseRouteTests.cs

示例10: ControllerContextFactory

        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;
            }
        }
开发者ID:wanaxe,项目名称:Study,代码行数:26,代码来源:ControllerContextCache.cs

示例11: AddNodeRecursive

        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;
        }
开发者ID:Sironfoot,项目名称:T3ME,代码行数:31,代码来源:RoutingSiteMapProvider.cs

示例12: GetHttpHandler

        /// <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;
        }
开发者ID:RifasRazick,项目名称:feather,代码行数:12,代码来源:MvcVersioningRouteHandler.cs

示例13: GetHttpHandler

        public IHttpHandler GetHttpHandler(RequestContext requestContext)
        {
            if (_httpHandler == null)
                _httpHandler = new ApplicationRouteHttpHandler(_url, _assembly);

            return _httpHandler;
        }
开发者ID:JoB70,项目名称:Bifrost,代码行数:7,代码来源:ApplicationRouteHandler.cs

示例14: GetHttpHandler

        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);
        }
开发者ID:johnsmith9264,项目名称:Mvc4Application1,代码行数:29,代码来源:MultiCultureMvcRouteHandler.cs

示例15: GetControllerTypeInternal

        /// <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);
        }
开发者ID:phaniarveti,项目名称:Experiments,代码行数:34,代码来源:MasterControllerFactory.cs


注:本文中的System.Web.Routing.RequestContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。