Commit e7b93b93 authored by Viet Hoang's avatar Viet Hoang

init project

parent 365221bf
<?xml version="1.0"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<settings>
<setting name="Vhs.SublayoutRenderingAndHybridPlaceholder.SublayoutRenderingId"
value="{A90C1805-2840-4763-8BA6-E05A8667BC46}" />
</settings>
<pipelines>
<mvc.buildPageDefinition>
<processor type="Vhs.SublayoutRenderingAndHybridPlaceholder.Pipelines.MvcBuildPageDefinition.SublayoutRenderingToMvcProcessor, Vhs.SublayoutRenderingAndHybridPlaceholder"
patch:after="*[@type='Sitecore.Mvc.Pipelines.Response.BuildPageDefinition.ProcessXmlBasedLayoutDefinition, Sitecore.Mvc']" />
</mvc.buildPageDefinition>
</pipelines>
</sitecore>
</configuration>
\ No newline at end of file
namespace Vhs.SublayoutRenderingAndHybridPlaceholder
{
public static class Constants
{
public struct ParameterTemplate
{
public static string SublayoutRenderingPath = "SublayoutRenderingPath";
}
}
}
\ No newline at end of file
using Sitecore.Collections;
using Sitecore.Mvc;
using Sitecore.Mvc.Presentation;
using Sitecore.Web;
using Sitecore.Web.UI.WebControls;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;
using System.Web.UI;
namespace Vhs.SublayoutRenderingAndHybridPlaceholder.Extensions
{
public static class SublayoutMvcAdapterExtensions
{
public static IHtmlString RenderSitecoreSublayout(this HtmlHelper html, string path)
{
var rendering = html.Sitecore().CurrentRendering;
return html.RenderSitecoreSubLayout(path, rendering.DataSource, rendering.Parameters);
}
public static IHtmlString RenderSitecoreSubLayout(this HtmlHelper html,
string path, string datasource = null, RenderingParameters parameters = null)
{
var page = new Page();
AddSublayoutToPage(page, path, datasource, parameters);
var result = ExecutePage(page);
return html.Raw(result);
}
private static void AddSublayoutToPage(Page page, string path, string datasource,
IEnumerable<KeyValuePair<string, string>> parameters)
{
var dict = new SafeDictionary<string>();
if (parameters != null)
{
parameters.ToList().ForEach(i => dict.Add(i.Key, i.Value));
}
var sublayout = new Sublayout
{
DataSource = datasource,
Path = path,
Parameters = WebUtil.BuildQueryString(dict, true, true)
};
var userControl = page.LoadControl(path) as UserControl;
RecursiveLoadControl(userControl, page);
sublayout.Controls.Add(userControl);
page.Controls.Add(sublayout);
}
public static void RecursiveLoadControl(UserControl userControl, Page page)
{
foreach (var c in userControl.Controls)
{
if (c is Sublayout)
{
var sl = (Sublayout)c;
var control = page.LoadControl(sl.Path) as UserControl;
control.Attributes.Add("sc_parameters", sl.Parameters);
control.Attributes.Add("sc_datasource", string.Empty);
RecursiveLoadControl(control, page);
sl.Controls.Add(control);
}
}
}
public static string RenderControl(Control control)
{
var sb = new StringBuilder();
var sw = new StringWriter(sb);
var writer = new HtmlTextWriter(sw);
control.RenderControl(writer);
return sb.ToString();
}
private static string ExecutePage(IHttpHandler page)
{
var text = new StringWriter();
HttpContext.Current.Server.Execute(page, text, true);
return text.ToString();
}
}
}
using Sitecore.Data;
using Sitecore.Data.Items;
using Sitecore.Mvc.Pipelines;
using Sitecore.Mvc.Pipelines.Response.BuildPageDefinition;
using Sitecore.Mvc.Presentation;
using System.Linq;
using Vhs.SublayoutRenderingAndHybridPlaceholder.Services;
namespace Vhs.SublayoutRenderingAndHybridPlaceholder.Pipelines.MvcBuildPageDefinition
{
public class SublayoutRenderingToMvcProcessor : BuildPageDefinitionProcessor
{
/// <summary>
/// Processes the specified BuildPageDefinitionArgs arguments.
/// </summary>
/// <param name="args">The BuildPageDefinitionArgs arguments.</param>
public override void Process(BuildPageDefinitionArgs args)
{
foreach (var rendering in args.Result.Renderings.Where(IsSublayout))
{
SwitchRenderings(args, rendering);
}
}
/// <summary>
/// Switches the renderings.
/// </summary>
/// <param name="args">The arguments.</param>
/// <param name="rendering">The rendering.</param>
private static void SwitchRenderings(MvcPipelineArgs args, Rendering rendering)
{
var sublayoutRenderingId = ConfigurationService.SublayoutRenderingId;
const string VIEW_RENDERING_TYPE_NAME = "View rendering";
var item = args.PageContext.Database.GetItem(ID.Parse(sublayoutRenderingId));
var renderingItem = new RenderingItem(item);
AddControlPathRenderingParameter(rendering);
rendering.RenderingItem = renderingItem;
rendering.RenderingType = VIEW_RENDERING_TYPE_NAME;
}
/// <summary>
/// Determines whether the specified rendering is sublayout.
/// </summary>
/// <param name="rendering">The rendering.</param>
/// <returns><c>true</c> if the specified rendering is sublayout, otherwise <c>false</c>.</returns>
private static bool IsSublayout(Rendering rendering)
{
return rendering.RenderingItem != null && rendering.RenderingItem.TagName == "Sublayout";
}
/// <summary>
/// Adds the control path rendering parameter.
/// </summary>
/// <param name="rendering">The rendering.</param>
private static void AddControlPathRenderingParameter(Rendering rendering)
{
const string PARAMETERS_FIELD_NAME = "Parameters";
const string PATH_FIELD_NAME = "Path";
var parameterString = rendering.RenderingItem.InnerItem[PARAMETERS_FIELD_NAME];
if (parameterString.Length > 0)
{
parameterString += "&";
}
rendering.Parameters =
new RenderingParameters(string.Concat(parameterString, Constants.ParameterTemplate.SublayoutRenderingPath + "=",
rendering.RenderingItem.InnerItem[PATH_FIELD_NAME]));
}
}
}
\ No newline at end of file
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Vhs.SublayoutRenderingAndHybridPlaceholder")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Vhs.SublayoutRenderingAndHybridPlaceholder")]
[assembly: AssemblyCopyright("Copyright © viet.hoang.sitecore@gmail.com 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("fbcf5fb8-8c69-47b1-b84c-b20b3298fa9c")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
using SC = Sitecore;
namespace Vhs.SublayoutRenderingAndHybridPlaceholder.Services
{
public static class ConfigurationService
{
public static string SublayoutRenderingId
=> SC.Configuration.Settings.GetSetting("Vhs.SublayoutRenderingAndHybridPlaceholder.SublayoutRenderingId", string.Empty);
}
}
\ No newline at end of file
using Sitecore.Data;
namespace Vhs.SublayoutRenderingAndHybridPlaceholder
{
public struct Templates
{
public struct Layout
{
public static readonly ID Id = new ID("{3A45A723-64EE-4919-9D41-02FD40FD1466}");
public struct Fields
{
public static readonly ID Path = new ID("{A036B2BC-BA04-44F6-A75F-BAE6CD242ABF}");
}
}
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props" Condition="Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" />
<Import Project="..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props" Condition="Exists('..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>
</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{D04C6A06-9CCF-4A90-A33D-035CB13F1771}</ProjectGuid>
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Vhs.SublayoutRenderingAndHybridPlaceholder</RootNamespace>
<AssemblyName>Vhs.SublayoutRenderingAndHybridPlaceholder</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<UseIISExpress>true</UseIISExpress>
<IISExpressSSLPort />
<IISExpressAnonymousAuthentication />
<IISExpressWindowsAuthentication />
<IISExpressUseClassicPipelineMode />
<UseGlobalApplicationHostFile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<Use64BitIISExpress />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Microsoft.Synchronization, Version=2.1.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\lib\Microsoft Sync Framework\Microsoft.Synchronization.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Synchronization.Files, Version=2.1.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\lib\Microsoft Sync Framework\Microsoft.Synchronization.Files.dll</HintPath>
</Reference>
<Reference Include="Sitecore.Kernel, Version=10.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Sitecore.Kernel.NoReferences.8.2.170728\lib\NET452\Sitecore.Kernel.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Sitecore.Mvc, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Sitecore.Mvc.NoReferences.8.2.170728\lib\NET452\Sitecore.Mvc.dll</HintPath>
</Reference>
<Reference Include="System.Web.DynamicData" />
<Reference Include="System.Web.Entity" />
<Reference Include="System.Web.ApplicationServices" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Core" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Drawing" />
<Reference Include="System.Web" />
<Reference Include="System.Xml" />
<Reference Include="System.Configuration" />
<Reference Include="System.Web.Services" />
<Reference Include="System.EnterpriseServices" />
</ItemGroup>
<ItemGroup>
<Reference Include="System.Web.Razor">
<HintPath>..\packages\Microsoft.AspNet.Razor.3.2.3\lib\net45\System.Web.Razor.dll</HintPath>
</Reference>
<Reference Include="System.Web.Webpages">
<HintPath>..\packages\Microsoft.AspNet.Webpages.3.2.3\lib\net45\System.Web.Webpages.dll</HintPath>
</Reference>
<Reference Include="System.Web.Webpages.Deployment">
<HintPath>..\packages\Microsoft.AspNet.Webpages.3.2.3\lib\net45\System.Web.Webpages.Deployment.dll</HintPath>
</Reference>
<Reference Include="System.Web.Webpages.Razor">
<HintPath>..\packages\Microsoft.AspNet.Webpages.3.2.3\lib\net45\System.Web.Webpages.Razor.dll</HintPath>
</Reference>
<Reference Include="System.Web.Helpers">
<HintPath>..\packages\Microsoft.AspNet.Webpages.3.2.3\lib\net45\System.Web.Helpers.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Web.Infrastructure">
<HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
</Reference>
<Reference Include="System.Web.Mvc">
<HintPath>..\packages\Microsoft.AspNet.Mvc.5.2.3\lib\net45\System.Web.Mvc.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Content Include="App_Config\Include\z.Vhs.SublayoutRenderingAndHybridPlaceholder.config">
<SubType>Designer</SubType>
</Content>
<None Include="Properties\PublishProfiles\Local.pubxml" />
<Content Include="Views\Shared\SublayoutRendering.cshtml" />
<None Include="Views\web.config" />
<None Include="Web.config" />
</ItemGroup>
<ItemGroup>
<Compile Include="Constants.cs" />
<Compile Include="Extensions\SublayoutMvcAdapterExtensions.cs" />
<Compile Include="Pipelines\MvcBuildPageDefinition\SublayoutRenderingToMvcProcessor.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Services\ConfigurationService.cs" />
<Compile Include="Templates.cs" />
<Compile Include="WebControls\HybridPlaceholder.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="Web.Debug.config">
<DependentUpon>Web.config</DependentUpon>
</None>
<None Include="Web.Release.config">
<DependentUpon>Web.config</DependentUpon>
</None>
</ItemGroup>
<ItemGroup />
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<UseIIS>True</UseIIS>
<AutoAssignPort>True</AutoAssignPort>
<DevelopmentServerPort>9229</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>http://localhost:9229/</IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
<UseCustomServer>False</UseCustomServer>
<CustomServerUrl>
</CustomServerUrl>
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
</WebProjectProperties>
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file
@using Sitecore.Mvc;
@using Vhs.SublayoutRenderingAndHybridPlaceholder.Extensions
@inherits System.Web.Mvc.WebViewPage
@{
var path = Html.Sitecore().CurrentRendering.Parameters[Vhs.SublayoutRenderingAndHybridPlaceholder.Constants.ParameterTemplate.SublayoutRenderingPath];
}
@if (!string.IsNullOrWhiteSpace(path))
{
@Html.RenderSitecoreSubLayout(path, Html.Sitecore().CurrentRendering.DataSource, Html.Sitecore().CurrentRendering.Parameters)
}
\ No newline at end of file
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</sectionGroup>
</configSections>
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="Vhs.SublayoutRenderingAndHybridPlaceholder" />
</namespaces>
</pages>
</system.web.webPages.razor>
<appSettings>
<add key="webpages:Enabled" value="false" />
</appSettings>
<system.webServer>
<handlers>
<remove name="BlockViewHandler"/>
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
</handlers>
</system.webServer>
<system.web>
<compilation>
<assemblies>
<add assembly="System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
</compilation>
</system.web>
</configuration>
<?xml version="1.0" encoding="utf-8"?>
<!-- For more information on using web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<!--
In the example below, the "SetAttributes" transform will change the value of
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator
finds an attribute "name" that has a value of "MyDB".
<connectionStrings>
<add name="MyDB"
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
-->
<system.web>
<!--
In the example below, the "Replace" transform will replace the entire
<customErrors> section of your web.config file.
Note that because there is only one customErrors section under the
<system.web> node, there is no need to use the "xdt:Locator" attribute.
<customErrors defaultRedirect="GenericError.htm"
mode="RemoteOnly" xdt:Transform="Replace">
<error statusCode="500" redirect="InternalError.htm"/>
</customErrors>
-->
</system.web>
</configuration>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!-- For more information on using web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<!--
In the example below, the "SetAttributes" transform will change the value of
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator
finds an attribute "name" that has a value of "MyDB".
<connectionStrings>
<add name="MyDB"
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
-->
<system.web>
<compilation xdt:Transform="RemoveAttributes(debug)" />
<!--
In the example below, the "Replace" transform will replace the entire
<customErrors> section of your web.config file.
Note that because there is only one customErrors section under the
<system.web> node, there is no need to use the "xdt:Locator" attribute.
<customErrors defaultRedirect="GenericError.htm"
mode="RemoteOnly" xdt:Transform="Replace">
<error statusCode="500" redirect="InternalError.htm"/>
</customErrors>
-->
</system.web>
</configuration>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=301880
-->
<configuration>
<appSettings>
<add key="webpages:Version" value="3.0.0.0"/>
<add key="webpages:Enabled" value="false"/>
<add key="ClientValidationEnabled" value="true"/>
<add key="UnobtrusiveJavaScriptEnabled" value="true"/>
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.6"/>
<httpRuntime targetFramework="4.6"/>
</system.web>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-5.2.3.0" newVersion="5.2.3.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs"
type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701"/>
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb"
type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+"/>
</compilers>
</system.codedom>
</configuration>
using Sitecore.Data;
using Sitecore.Data.Items;
using Sitecore.Mvc.Pipelines.Response.RenderPlaceholder;
using Sitecore.Mvc.Presentation;
using Sitecore.Pipelines;
using System.IO;
using System.Web.UI;
namespace Vhs.SublayoutRenderingAndHybridPlaceholder.WebControls
{
public class HybridPlaceholder : Sitecore.Web.UI.WebControls.Placeholder
{
protected override void Render(HtmlTextWriter writer)
{
var currentRendering = RenderingContext.CurrentOrNull?.Rendering;
if (currentRendering == null)
{
base.Render(writer);
return;
}
if (!IsMvcLayout(new ID(currentRendering.LayoutId)))
{
base.Render(writer);
return;
}
RenderMvcPlaceholder(ContextKey, writer, currentRendering);
}
private void RenderMvcPlaceholder(string placeholder, TextWriter writer, Rendering ownerRendering)
{
const string pipeline = "mvc.renderPlaceholder";
var args = new RenderPlaceholderArgs(Key,
writer,
ownerRendering);
CorePipeline.Run(pipeline, args);
}
private bool IsMvcLayout(ID layoutId)
{
Item layoutItem = Sitecore.Context.Database.GetItem(layoutId);
var layoutPath = layoutItem[Templates.Layout.Fields.Path];
return !string.IsNullOrWhiteSpace(layoutPath) && layoutPath.EndsWith(".cshtml");
}
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.AspNet.Mvc" version="5.2.3" targetFramework="net46" />
<package id="Microsoft.AspNet.Razor" version="3.2.3" targetFramework="net46" />
<package id="Microsoft.AspNet.WebPages" version="3.2.3" targetFramework="net46" />
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="1.0.0" targetFramework="net46" />
<package id="Microsoft.Net.Compilers" version="1.0.0" targetFramework="net46" developmentDependency="true" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net46" />
<package id="Sitecore.Kernel.NoReferences" version="8.2.170728" targetFramework="net46" developmentDependency="true" />
<package id="Sitecore.Mvc.NoReferences" version="8.2.170728" targetFramework="net46" developmentDependency="true" />
</packages>
\ No newline at end of file

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
# Visual Studio 15
VisualStudioVersion = 15.0.27004.2010
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Vhs.ContentAuditTool", "Vhs.ContentAuditTool\Vhs.ContentAuditTool.csproj", "{7D9B975E-5109-4E68-AD72-93BD1C9F8DF0}"