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


C# PublishedContentRequest.UpdateOnMissingTemplate方法代码示例

本文整理汇总了C#中Umbraco.Web.Routing.PublishedContentRequest.UpdateOnMissingTemplate方法的典型用法代码示例。如果您正苦于以下问题:C# PublishedContentRequest.UpdateOnMissingTemplate方法的具体用法?C# PublishedContentRequest.UpdateOnMissingTemplate怎么用?C# PublishedContentRequest.UpdateOnMissingTemplate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Umbraco.Web.Routing.PublishedContentRequest的用法示例。


在下文中一共展示了PublishedContentRequest.UpdateOnMissingTemplate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetHandlerForRoute

		/// <summary>
		/// this will determine the controller and set the values in the route data
		/// </summary>
		/// <param name="requestContext"></param>
		/// <param name="publishedContentRequest"></param>
		internal IHttpHandler GetHandlerForRoute(RequestContext requestContext, PublishedContentRequest publishedContentRequest)
		{
		    if (requestContext == null) throw new ArgumentNullException("requestContext");
		    if (publishedContentRequest == null) throw new ArgumentNullException("publishedContentRequest");

		    var routeDef = GetUmbracoRouteDefinition(requestContext, publishedContentRequest);
            
			//Need to check for a special case if there is form data being posted back to an Umbraco URL
			var postedInfo = GetFormInfo(requestContext);
			if (postedInfo != null)
			{
				return HandlePostedValues(requestContext, postedInfo);
			}

			//here we need to check if there is no hijacked route and no template assigned, if this is the case
			//we want to return a blank page, but we'll leave that up to the NoTemplateHandler.
			if (!publishedContentRequest.HasTemplate && !routeDef.HasHijackedRoute)
			{
				publishedContentRequest.UpdateOnMissingTemplate(); // will go 404

                // HandleHttpResponseStatus returns a value indicating that the request should
                // not be processed any further, eg because it has been redirect. then, exit.
			    if (UmbracoModule.HandleHttpResponseStatus(requestContext.HttpContext, publishedContentRequest))
			        return null;

                var handler = GetHandlerOnMissingTemplate(publishedContentRequest);

				// if it's not null it can be either the PublishedContentNotFoundHandler (no document was
				// found to handle 404, or document with no template was found) or the WebForms handler 
				// (a document was found and its template is WebForms)

				// if it's null it means that a document was found and its template is Mvc

				// if we have a handler, return now
				if (handler != null)
					return handler;

				// else we are running Mvc
                // update the route data - because the PublishedContent has changed
                UpdateRouteDataForRequest(
                    new RenderModel(publishedContentRequest.PublishedContent, publishedContentRequest.Culture),
                    requestContext);
                // update the route definition
				routeDef = GetUmbracoRouteDefinition(requestContext, publishedContentRequest);
			}

			//no post values, just route to the controller/action requried (local)

			requestContext.RouteData.Values["controller"] = routeDef.ControllerName;
			if (!string.IsNullOrWhiteSpace(routeDef.ActionName))
			{
				requestContext.RouteData.Values["action"] = routeDef.ActionName;
			}

            // Set the session state requirements
            requestContext.HttpContext.SetSessionStateBehavior(GetSessionStateBehavior(requestContext, routeDef.ControllerName));

			// reset the friendly path so in the controllers and anything occuring after this point in time,
			//the URL is reset back to the original request.
			requestContext.HttpContext.RewritePath(UmbracoContext.OriginalRequestUrl.PathAndQuery);

            return new UmbracoMvcHandler(requestContext);
		}
开发者ID:phaniarveti,项目名称:Experiments,代码行数:68,代码来源:RenderRouteHandler.cs


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