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


C# Mvc.MvcHttpHandler类代码示例

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


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

示例1: Page_Load

        public void Page_Load(object sender, System.EventArgs e)
        {
            HttpContext.Current.RewritePath(Request.ApplicationPath, false);
            IHttpHandler httpHandler = new MvcHttpHandler();

            httpHandler.ProcessRequest(HttpContext.Current);
        }
开发者ID:cbilson,项目名称:nationalloanservicing,代码行数:7,代码来源:Default.aspx.cs

示例2: ExecuteResult

        public override void ExecuteResult(ControllerContext context)
        {
            //Get url
            string url = "";
            if (!string.IsNullOrEmpty(_url)) url = _url;
            else
            {
                //Create route
                var routeValues = new RouteValueDictionary(_Values);
                routeValues.Add("Action", _Action);
                routeValues.Add("Controller", _Controller);

                //Must persist ajax
                var request = HttpContext.Current.Request;
                if ((request["X-Requested-With"] != null &&
                    request["X-Requested-With"].Equals("XmlHttpRequest", StringComparison.InvariantCultureIgnoreCase)) ||
                    request.QueryString["_"] != null ||
                    context.HttpContext.Items["__IsAjaxRequest"] != null)
                    routeValues.Add("X-Requested-With", "XmlHttpRequest");

                url = RouteTable.Routes.GetVirtualPath(context.RequestContext, routeValues).VirtualPath;
            }

            HttpContext.Current.RewritePath(url, false);
            IHttpHandler httpHandler = new MvcHttpHandler();
            httpHandler.ProcessRequest(HttpContext.Current);

            //httpContext.Server.TransferRequest(url, true);
        }
开发者ID:exsurgo,项目名称:mvcajaxer,代码行数:29,代码来源:TransferResult.cs

示例3: ServerTransferToRoute

        /// <summary>
        /// Redirect to another route using a server side transfer (so the client URL does not change)
        /// </summary>
        /// <param name="context"></param>
        /// <param name="routeValues"></param>
        private void ServerTransferToRoute(ActionExecutingContext context, object routeValues)
        {
            var httpContextBase = context.HttpContext;

            var rc = new RequestContext(httpContextBase, context.RouteData);
            string url = RouteTable.Routes.GetVirtualPath(rc,
                new RouteValueDictionary(routeValues)).VirtualPath;

            // MVC 3 running on IIS 7+
            if (HttpRuntime.UsingIntegratedPipeline)
            {
                httpContextBase.Server.TransferRequest(url, true);
            }
            else
            {
                // Pre IIS7

                // Get the current application to get the real HttpContext
                var app = (HttpApplication)httpContextBase.GetService(typeof(HttpApplication));

                // Rewrite the path of the request
                httpContextBase.RewritePath(url, false);

                // Process the modified request
                IHttpHandler httpHandler = new MvcHttpHandler();
                httpHandler.ProcessRequest(app.Context);
            }
        }
开发者ID:opencolorado,项目名称:.NET-Wrapper-for-CKAN-API,代码行数:33,代码来源:CheckOfflineAttribute.cs

示例4: Page_Load

 protected void Page_Load(object sender, EventArgs e)
 {
     string originalPath = Request.Path;
     HttpContext.Current.RewritePath(Request.ApplicationPath, false);
     IHttpHandler httpHandler = new MvcHttpHandler();
     httpHandler.ProcessRequest(HttpContext.Current);
     HttpContext.Current.RewritePath(originalPath, false);
 }
开发者ID:statianzo,项目名称:WindsorMefMvc,代码行数:8,代码来源:Default.aspx.cs

示例5: Page_Load

 protected void Page_Load(object sender, EventArgs e)
 {
     string path = Request.Path;
     HttpContext.Current.RewritePath(Request.ApplicationPath,false);
     IHttpHandler handler = new System.Web.Mvc.MvcHttpHandler();
     handler.ProcessRequest(HttpContext.Current);
     HttpContext.Current.RewritePath(path);
 }
开发者ID:JPomichael,项目名称:IPOW,代码行数:8,代码来源:default.aspx.cs

示例6: ExecuteResult

        public override void ExecuteResult(ControllerContext context)
        {
            var httpContext = HttpContext.Current;

            httpContext.RewritePath(Url, true);

            IHttpHandler httpHandler = new MvcHttpHandler();
            httpHandler.ProcessRequest(HttpContext.Current);
        }
开发者ID:tyronegroves,项目名称:Bennington,代码行数:9,代码来源:ContentTreeSectionController.cs

示例7: Page_Load

		public void Page_Load(object sender, System.EventArgs e) {
			// Change the current path so that the Routing handler can correctly interpret
			// the request, then restore the original path so that the OutputCache module
			// can correctly process the response (if caching is enabled).
			string originalPath = Request.Path;
			HttpContext.Current.RewritePath(Request.ApplicationPath, false);
			IHttpHandler httpHandler = new MvcHttpHandler();
			httpHandler.ProcessRequest(HttpContext.Current);
			HttpContext.Current.RewritePath(originalPath, false);
		}
开发者ID:437072341,项目名称:dotnetopenid,代码行数:10,代码来源:Default.aspx.cs

示例8: OnLoad

        /// <summary>
        /// Raises the page's Load event.
        /// </summary>
        /// <param name="e">The event arguments.</param>
        protected override void OnLoad(EventArgs e)
        {
            string originalPath = Request.Path;
            HttpContext.Current.RewritePath(Request.ApplicationPath, false);
            IHttpHandler httpHandler = new MvcHttpHandler();
            httpHandler.ProcessRequest(HttpContext.Current);
            HttpContext.Current.RewritePath(originalPath, false);

            base.OnLoad(e);
        }
开发者ID:ChadBurggraf,项目名称:blue-collar,代码行数:14,代码来源:default.aspx.cs

示例9: Application_Error

        protected void Application_Error(object sender, EventArgs eventArgs)
        {
            if (!HttpContext.Current.IsCustomErrorEnabled)
            {
                // Don't handle the error in this case.

                return;
            }

            var exception = HttpContext.Current.Server.GetLastError();
            exception = exception == null ? exception : exception.GetBaseException();

            // Log the error here in some way. This example uses ELMAH so logging is handled via a module.

            var appRelativePath = HttpContext.Current.Request.AppRelativeCurrentExecutionFilePath;

            if (appRelativePath.StartsWith("~/" + ErrorControllerName + "/", StringComparison.OrdinalIgnoreCase))
            {
                TransferToFatalErrorPage();
                return;
            }

            const string errorRoute = "~/" + ErrorControllerName + "/ServerError";

            try
            {
                if (HttpRuntime.UsingIntegratedPipeline)
                {
                    // For IIS 7+

                    HttpContext.Current.Server.TransferRequest(errorRoute, false, "GET", null);
                }
                else
                {
                    // For IIS 6

                    var originalPath = HttpContext.Current.Request.Path;
                    HttpContext.Current.RewritePath(errorRoute);

                    IHttpHandler handler = new MvcHttpHandler();
                    handler.ProcessRequest(HttpContext.Current);

                    HttpContext.Current.RewritePath(originalPath);
                    HttpContext.Current.Server.ClearError();
                }
            }
            catch (Exception)
            {
                // Log the error here in some way.

                TransferToFatalErrorPage();
            }
        }
开发者ID:stevejay,项目名称:MvcErrorHandlingStrategies,代码行数:53,代码来源:Global.asax.cs

示例10: Page_Load

        public void Page_Load(object sender, System.EventArgs e)
        {
            // 改变当前路径路由处理程序可以正确解释请求,
            // 然后恢复原来的路径,以便在OutputCache模块
            // 可以正确处理响应(如果缓存已启用).

            string originalPath = Request.Path;
            HttpContext.Current.RewritePath(Request.ApplicationPath, false);
            IHttpHandler httpHandler = new MvcHttpHandler();
            httpHandler.ProcessRequest(HttpContext.Current);
            HttpContext.Current.RewritePath(originalPath, false);
        }
开发者ID:zealoussnow,项目名称:OneCode,代码行数:12,代码来源:Default.aspx.cs

示例11: Transfer

        public static void Transfer(ControllerContext filterContext, string url)
        {
            lock (objectTransfer)
            {
                // Rewrite path
                HttpContext.Current.RewritePath(GetPath(filterContext, url), false);

                IHttpHandler httpHandler = new System.Web.Mvc.MvcHttpHandler();

                // Process request
                httpHandler.ProcessRequest(HttpContext.Current);
                filterContext.HttpContext.Response.End();
            }
        }
开发者ID:NGITechnology,项目名称:BeymenCheckout,代码行数:14,代码来源:MvcUtils.cs

示例12: ExecuteResult

        public override void ExecuteResult(ControllerContext context)
        {
            // MVC 3 running on IIS 7+
            if (HttpRuntime.UsingIntegratedPipeline)
            {
                context.HttpContext.Server.TransferRequest(_url);
                //context.HttpContext.Server.TransferRequest(_url, true);
            }
            else
            {
                // Pre MVC 3
                context.HttpContext.RewritePath(_url, false);

                IHttpHandler httpHandler = new MvcHttpHandler();
                httpHandler.ProcessRequest(context.HttpContext.ApplicationInstance.Context);
            }
        }
开发者ID:jimlyndon,项目名称:cloudcre,代码行数:17,代码来源:TransferRequestResult.cs

示例13: Page_PreInit

        protected void Page_PreInit(object sender, System.EventArgs e)
        {
            string url = "/";
            var httpContext = HttpContext.Current;

            //MVC 3 running on IIS 7+
            if (HttpRuntime.UsingIntegratedPipeline)
            {
                httpContext.Server.TransferRequest(url, true);
            }
            else
            {
                // Pre MVC 3
                httpContext.RewritePath(url, false);
                IHttpHandler httpHandler = new MvcHttpHandler();
                httpHandler.ProcessRequest(httpContext);
            }
        }
开发者ID:rajulaggarwal,项目名称:Level3,代码行数:18,代码来源:Default.aspx.cs

示例14: ExecuteResult

        public override void ExecuteResult(ControllerContext context)
        {
            using (new TransactionScope(TransactionScopeOption.RequiresNew)) {
                var httpContext = HttpContext.Current;

                // See http://stackoverflow.com/questions/799511/how-to-simulate-server-transfer-in-asp-net-mvc/799534
                // MVC 3 running on IIS 7+
                if (HttpRuntime.UsingIntegratedPipeline) {
                    httpContext.Server.TransferRequest(Url, true);
                }
                else {
                    // Pre MVC 3
                    httpContext.RewritePath(Url, false);

                    IHttpHandler httpHandler = new MvcHttpHandler();
                    httpHandler.ProcessRequest(httpContext);
                }
            }
        }
开发者ID:robertbird,项目名称:BoomJennies,代码行数:19,代码来源:TransferResult.cs

示例15: Application_Error

        void Application_Error(object sender, EventArgs e)
        {
            var error = Server.GetLastError();
            var code = (error is HttpException) ? (error as HttpException).GetHttpCode() : 500;

            if (code != 404)
            {
                //
            }

            Response.Clear();
            Server.ClearError();

            string path = Request.Path;
            Context.RewritePath(string.Format("~/Errors/Http{0}", code), false);
            IHttpHandler httpHandler = new MvcHttpHandler();
            httpHandler.ProcessRequest(Context);
            Context.RewritePath(path, false);
        }
开发者ID:paulmd3,项目名称:mpx_mobile,代码行数:19,代码来源:Global.asax.cs


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