Pipeline
ØA pipeline is a series of actions that execute in sequence to perform a task in Sitecore.
Ø Pipelines are fundamental to Sitecore's basic architecture. Most processes in Sitecore are defined as pipelines.
ØPipelines can be modified by developers to change, add, or remove functionality from Sitecore.
Why Pipeline?
ØPipelines are one of Sitecore’s essential integration concepts.
ØThey is used to extend existing functionality, and to allow custom functionality to be extended in the future.
Processor
ØPipelines are made up of one or more steps - called "processors."
ØWe can see the Pipelines this url
http://<hostName>/sitecore/admin/showconfig.aspx
Pipeline Example
HttpBeginRequest Pipeline
ØThe processors in the HttpBeginRequest pipeline generate and populate the Sitecore.Context class.
ØIn my Application, We have the httpRequestBegin Pipeline with 30 processors.
ØWhen the httpRequestBegin pipeline is executed, the processors defined above run in order from first to last.
Demo
Handle the 500 Exception in web pages
ØCurrently I can see the errors on my page. It’s not good to show to our live site.
Create a class file
public class Handle500Exception: ExceptionProcessor
{
public override void Process(ExceptionArgs args)
{
try
{
ExceptionContent objex = new ExceptionContent();
HttpContext httpContext = HttpContext.Current;
httpContext.Server.ClearError();
httpContext.Response.TrySkipIisCustomErrors = true;
httpContext.Response.StatusCode = 500;
httpContext.Response.Write(objex.GenerateExceptionPage());
}
catch (Exception ex)
{
Log.Info(string.Format("Process -- error message -- {0} stacktrace {1} ", ex.Message.ToString(), ex.StackTrace.ToString()), ex);
}
}
}
public class ExceptionContent
{
public string GenerateExceptionPage()
{
var context = System.Web.HttpContext.Current;
string content = string.Empty;
try
{
string domain = context.Request.Url.GetComponents(UriComponents.Scheme | UriComponents.Host, UriFormat.Unescaped);
string errorPageLink = "/500";
if (!string.IsNullOrEmpty(errorPageLink))
{
content = Sitecore.Web.WebUtil.ExecuteWebPage(string.Concat(domain, errorPageLink));
Log.Error("Internal server error happened: " + context.Request.Url, this);
}
}
catch (Exception ex)
{
Sitecore.Diagnostics.Log.Error("Error happened while generating ExceptionPage for 500 Error :" + ex.Message, this);
return string.Empty;
}
return content;
}
}
Create a config file
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:set="http://www.sitecore.net/xmlconfig/set/" xmlns:role="http://www.sitecore.net/xmlconfig/role/">
<sitecore>
<pipelines>
<mvc.exception>
<processor type="Sitecore.Mvc.Pipelines.MvcEvents.Exception.ShowAspNetErrorMessage, Sitecore.Mvc">
<patch:attribute name="type">Sitecon.Project.CustomPipeline.Pipeline.Handle500Exception, Sitecon.Project.CustomPipeline</patch:attribute>
</processor>
</mvc.exception>
</pipelines>
</sitecore>
</configuration>
Create New 500 Page in Sitecore
Before publishing check the ShowConfig File
ØSorry, I forget to publish my 500 pages to web database.
No comments:
Post a Comment