• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Mvc.MvcHttpHandler类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: ExecuteResult

        public override void ExecuteResult(ControllerContext context)
        {
            if (context == null)
                throw new ArgumentNullException("context");

            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:MattLud,项目名称:SymbolSource.Community,代码行数:21,代码来源:DefaultController.cs


示例17: ExecuteResult

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

            //Transfering breaks temp data so just destroy it.  You wont need it on the error page anyway.
            context.Controller.TempData.Clear();

            // MVC 3 running on IIS 7+
            if (HttpRuntime.UsingIntegratedPipeline)
            {
                httpContext.Server.TransferRequest(Url, false);
            }
            else
            {
                // Pre MVC 3
                var thisJttpContext = context.HttpContext;
                thisJttpContext.RewritePath(Url, false);
                IHttpHandler httpHandler = new MvcHttpHandler();
                httpHandler.ProcessRequest(HttpContext.Current);
            }
        }
开发者ID:basicdays,项目名称:Guidelines,代码行数:21,代码来源:TransferResult.cs


示例18: Page_Load

 protected void Page_Load(object sender, EventArgs e)
 {
     if (Request.ApplicationPath != null) HttpContext.Current.RewritePath(Request.ApplicationPath);
     IHttpHandler httpHandler = new MvcHttpHandler();
     httpHandler.ProcessRequest(HttpContext.Current);
 }
开发者ID:santhoshinet,项目名称:SruthiLaya,代码行数:6,代码来源:Default.aspx.cs


示例19: RenderAction

        protected void RenderAction(string actionName, string controllerName, object routeValues)
        {
            //Get Url
            RouteValueDictionary routes = null;
            if (routeValues != null) routes = new RouteValueDictionary(routeValues);
            else routes = new RouteValueDictionary();
            routes.Add("Action", actionName);
            if (!string.IsNullOrEmpty(controllerName)) routes.Add("Controller", controllerName);
            else routes.Add("Controller", this.ControllerContext.RouteData.Values["Controller"].ToString());
            var url = RouteTable.Routes.GetVirtualPath(this.ControllerContext.RequestContext, routes).VirtualPath;

            //Rewrite path
            System.Web.HttpContext.Current.RewritePath(url, false);
            IHttpHandler httpHandler = new MvcHttpHandler();
            httpHandler.ProcessRequest(System.Web.HttpContext.Current);

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


示例20: FileNotFoundHandler

        public virtual void FileNotFoundHandler(object sender, EventArgs evt)
        {
            // Check if this should be enabled
            if (_redirectConfiguration.FileNotFoundHandlerMode == FileNotFoundMode.Off)
                return;

            Logger.Debug("FileNotFoundHandler called");

            HttpContext context = HttpContext.Current;
            if (context == null)
            {
                Logger.Debug("No HTTPContext, returning");
                return;
            }

            if (context.Response.StatusCode != 404)
                return;
            var query = context.Request.ServerVariables["QUERY_STRING"];
            if ((query != null) && query.StartsWith("404;"))
            {
                return;
            }

            Uri notFoundUri = context.Request.Url;

            // Skip resource files
            if (IsResourceFile(notFoundUri))
                return;

            // If we're only doing this for remote users, we need to test for local host
            if (_redirectConfiguration.FileNotFoundHandlerMode == FileNotFoundMode.RemoteOnly)
            {
                // Determine if we're on localhost
                bool localHost = IsLocalhost();
                if (localHost)
                {
                    Logger.Debug("Determined to be localhost, returning");
                    return;
                }
                Logger.Debug("Not localhost, handling error");
            }

            // Avoid looping forever
            if (IsInfiniteLoop(context))
                return;

            var redirect = HandleRequest(GetReferer(context.Request.UrlReferrer), notFoundUri);
            if (redirect.Redirected)
                context.Response.RedirectPermanent(redirect.NewUrl);
            else
            {
                string url = Get404Url();

                context.Response.Clear();
                context.Response.TrySkipIisCustomErrors = true;
                context.Server.ClearError();

                // do the redirect to the 404 page here
                if (HttpRuntime.UsingIntegratedPipeline)
                {
                    context.Server.TransferRequest(url, true);
                }
                else
                {
                    context.RewritePath(url, false);
                    IHttpHandler httpHandler = new MvcHttpHandler();
                    httpHandler.ProcessRequest(context);
                }
                // return the original status code to the client
                // (this won't work in integrated pipleline mode)
                context.Response.StatusCode = 404;
            }
        }
开发者ID:JoachimL,项目名称:Creuna.Episerver.RedirectHandler,代码行数:73,代码来源:Custom404Handler.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Mvc.ResultExecutedContext类代码示例发布时间:2022-05-26
下一篇:
C# Mvc.MvcHtmlString类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap