Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions docs/en/framework/ui/mvc-razor-pages/page-header.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,22 @@

`IPageLayout` can be injected in any page/view to set the page header properties.

### RenderLayoutElements

The `RenderLayoutElements` property controls whether the application layout (navigation menu, toolbar, etc.) should be rendered around the page content:

```csharp
@inject IPageLayout PageLayout
@{
PageLayout.RenderLayoutElements = false; // Hide navigation and layout elements
}
```

* When set to `true` (default), the full application layout including navigation menu is rendered.
* When set to `false`, only the page content is rendered without the surrounding layout elements.
* This is useful for pages public pages, error pages, or embedded content where you want a clean layout without navigation.
* This is not `Empty` Layout, it's still the same layout with related page, but without the navigation menu, toolbar and footer. All the layout hooks are still available.

### Page Title

Page Title can be set as shown in the example below:
Expand Down
1,955 changes: 1,955 additions & 0 deletions framework/Volo.Abp.sln

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<ConfigureAwait ContinueOnCapturedContext="false" />
</Weavers>
30 changes: 30 additions & 0 deletions framework/src/Volo.Abp.AspNetCore.Mvc.UI.Embedding/FodyWeavers.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. -->
<xs:element name="Weavers">
<xs:complexType>
<xs:all>
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" />
</xs:complexType>
</xs:element>
</xs:all>
<xs:attribute name="VerifyAssembly" type="xs:boolean">
<xs:annotation>
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="VerifyIgnoreCodes" type="xs:string">
<xs:annotation>
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="GenerateXsd" type="xs:boolean">
<xs:annotation>
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"role": "lib.framework"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<Import Project="..\..\..\configureawait.props" />
<Import Project="..\..\..\common.props" />

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<WarningsAsErrors>Nullable</WarningsAsErrors>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
<AssemblyName>Volo.Abp.AspNetCore.Mvc.UI.Embedding</AssemblyName>
<PackageId>Volo.Abp.AspNetCore.Mvc.UI.Embedding</PackageId>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>
<IsPackable>true</IsPackable>
<OutputType>Library</OutputType>
<RootNamespace />
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Volo.Abp.AspNetCore.Mvc.UI\Volo.Abp.AspNetCore.Mvc.UI.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.AspNetCore.Mvc.UI.Embedding.Volo.Abp.AspNetCore.Mvc.UI.Layout.EmbeddedScript;
using Volo.Abp.AspNetCore.Mvc.UI.Layout;
using Volo.Abp.AspNetCore.Mvc.UI.Theming;
using Volo.Abp.Modularity;
using Volo.Abp.Ui.LayoutHooks;
using Volo.Abp.UI.Navigation;
using Volo.Abp.VirtualFileSystem;

namespace Volo.Abp.AspNetCore.Mvc.UI;

[DependsOn(typeof(AbpAspNetCoreMvcUiModule))]
public class AbpAspNetCoreMvcUiEmbeddingModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<AbpVirtualFileSystemOptions>(options =>
{
options.FileSets.AddEmbedded<AbpAspNetCoreMvcUiEmbeddingModule>();
});

// Configure page embedding options
Configure<PageEmbeddingOptions>(options =>
{
// Default configuration - can be overridden by applications
});

Configure<AbpLayoutHookOptions>(options =>
{
options.Add(
LayoutHooks.Body.Last,
typeof(EmbeddedScriptViewComponent)
);
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@using Volo.Abp.AspNetCore.Mvc.UI.Layout
@inject EmbeddingPageLayout PageLayout


@if (PageLayout.IsEmbedded)
{
<script src="/libs/abp/embedding/abp-embedding-iframe.js">
</script>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;

namespace Volo.Abp.AspNetCore.Mvc.UI.Embedding.Volo.Abp.AspNetCore.Mvc.UI.Layout.EmbeddedScript;

public class EmbeddedScriptViewComponent : AbpViewComponent
{
public virtual IViewComponentResult Invoke()
{
return View("~/Volo/Abp/AspNetCore/Mvc/UI/Layout/EmbeddedScript/Default.cshtml");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using Microsoft.AspNetCore.Http;
using Volo.Abp.DependencyInjection;

namespace Volo.Abp.AspNetCore.Mvc.UI.Layout;

[Dependency(ReplaceServices = true)]
[ExposeServices(typeof(IPageLayout), typeof(EmbeddingPageLayout))]
public class EmbeddingPageLayout : PageLayout, IScopedDependency
{
public bool IsEmbedded { get; protected set; }
protected IPageEmbeddingService PageEmbeddingService { get; }
protected IHttpContextAccessor HttpContextAccessor { get; }

private bool? _renderLayoutElements;

public EmbeddingPageLayout(IPageEmbeddingService pageEmbeddingService, IHttpContextAccessor httpContextAccessor)
{
PageEmbeddingService = pageEmbeddingService;
HttpContextAccessor = httpContextAccessor;
}

public override bool RenderLayoutElements
{
get
{
if (_renderLayoutElements.HasValue)
{
return _renderLayoutElements.Value;
}

// Check if this is an embedding request
var httpContext = HttpContextAccessor.HttpContext;
if (httpContext != null && PageEmbeddingService.IsEmbeddingRequest(httpContext))
{
IsEmbedded = true;
return false;
}

return true;
}
set => _renderLayoutElements = value;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using Microsoft.AspNetCore.Http;

namespace Volo.Abp.AspNetCore.Mvc.UI.Layout;

public interface IPageEmbeddingService
{
/// <summary>
/// Determines if the current request should render the page in embedding mode (without layout elements)
/// </summary>
/// <param name="httpContext">The current HTTP context</param>
/// <returns>True if the page should be rendered without layout elements</returns>
bool IsEmbeddingRequest(HttpContext httpContext);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System.Collections.Generic;

namespace Volo.Abp.AspNetCore.Mvc.UI.Layout;

public class PageEmbeddingOptions
{
/// <summary>
/// Query parameter name to enable embedding mode. Default: "embed"
/// </summary>
public string QueryParameterName { get; set; } = "embed";

/// <summary>
/// Query parameter values that enable embedding mode. Default: ["true", "1"]
/// </summary>
public HashSet<string> QueryParameterValues { get; set; } = new() { "true", "1" };

/// <summary>
/// Paths that should always be rendered without layout elements (for embedding)
/// </summary>
public HashSet<string> EmbeddedPaths { get; set; } = new();

/// <summary>
/// Path patterns that should always be rendered without layout elements (for embedding)
/// Supports wildcards like "/api/embed/*"
/// </summary>
public HashSet<string> EmbeddedPathPatterns { get; set; } = new();

/// <summary>
/// When true, automatically disable layout elements for requests that come from iframes.
/// Uses multiple detection methods with fallbacks.
/// </summary>
public bool AlwaysEmbedIFrameRequests { get; set; } = false;
}
Loading