Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.