Skip to content

Instantly share code, notes, and snippets.

@RobsonAutomator
Last active March 14, 2019 08:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RobsonAutomator/45fd645a189fd9d7aea1c57fbdbf8438 to your computer and use it in GitHub Desktop.
Save RobsonAutomator/45fd645a189fd9d7aea1c57fbdbf8438 to your computer and use it in GitHub Desktop.
Show Sitecore Config - can be useful for CD servers
@using Sitecore.Configuration
<!-- Author: Robert Senktas vel RobsonAutomator -->
<!-- Remove this file from server after usage -->
<!-- http://<hostname>/showconfig.cshtml?save=true saves xml to the App_Data folder -->
@{
if (!Context.Request.IsLocal)
{
Response.StatusCode = 404;
return;
}
var xmlDocument = Factory.GetConfiguration();
if (Request.QueryString.HasKeys() && Request.QueryString.AllKeys.Any(x => x.Equals("save")))
{
var appDataPath = Context.Request.MapPath("~/App_Data");
if (!string.IsNullOrWhiteSpace(appDataPath))
{
var xmlPath = Path.Combine(appDataPath, $"{Context.Server.MachineName}-Config.xml");
xmlDocument.Save(xmlPath);
}
}
Response.ContentType = "text/xml";
Response.Write(xmlDocument.OuterXml);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment