Open Closed

WithVirtualFilePath + azure app service #8601


User avatar
0
LiSong created
  • ABP Framework version: v9.0.0
  • UI Type: MVC
  • Database System: EF Core (SQL Server
  • Tiered (for MVC) or Auth Server Separated (for Angular): no
  • Exception message and full stack trace:
  • Steps to reproduce the issue:

I am using text template:

        context.Add(
            new TemplateDefinition("StandardEmailTemplates") 
                .WithVirtualFilePath(
                    "/Demos/Hello/StandardEmailTemplates.html", //template content path
                    isInlineLocalized: true
                )
        );
        context.Add(
            new TemplateDefinition(TextTemplates.TrustInvitationEmailTemplate)
                .WithVirtualFilePath(
                    "/TextTemplates/TrustInvitationEmailTemplate.html", 
                    isInlineLocalized: true
                )
        );

    }
    

it works locally, but after I published it to Azure app service, it failed and gave me errors, even if I can see the files in the server: wwwroot/TextTemplates/TrustInvitationEmailTemplate.html:

2025-01-07 05:28:12.699 +00:00 [Error] Could not find a file/folder at the location: /TextTemplates/TrustInvitationEmailTemplate.html
Volo.Abp.AbpException: Could not find a file/folder at the location: /TextTemplates/TrustInvitationEmailTemplate.html
   at Volo.Abp.TextTemplating.VirtualFiles.LocalizedTemplateContentReaderFactory.CreateInternalAsync(TemplateDefinition templateDefinition)
   at Volo.Abp.TextTemplating.VirtualFiles.LocalizedTemplateContentReaderFactory.CreateAsync(TemplateDefinition templateDefinition)
   at Volo.Abp.TextTemplating.VirtualFiles.VirtualFileTemplateContentContributor.GetOrNullAsync(TemplateContentContributorContext context)
   at Volo.Abp.TextTemplating.TemplateContentProvider.GetContentOrNullAsync(ITemplateContentContributor[] contributors, TemplateContentContributorContext context)
   at Volo.Abp.TextTemplating.TemplateContentProvider.GetContentOrNullAsync(TemplateDefinition templateDefinition, String cultureName, Boolean tryDefaults, Boolean useCurrentCultureIfCultureNameIsNull)
   at Volo.Abp.TextTemplateManagement.TextTemplates.TemplateContentAppService.GetAsync(GetTemplateContentInput input)
   at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)

any suggestions?

Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

8 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    wwwroot/TextTemplates/TrustInvitationEmailTemplate.html:

    Is the wwwroot website a root folder or assets folder?

    Please share the csproj file content containing the TrustInvitationEmailTemplate.html file.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    LiSong created
    <Project Sdk="Microsoft.NET.Sdk.Web">
    
      <Import Project="..\..\common.props" />
    
      <PropertyGroup>
        <TargetFramework>net9.0</TargetFramework>
        <Nullable>enable</Nullable>
        <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
        <RootNamespace>Tapp.Web</RootNamespace>
        <AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>
        <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
        <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
        <GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
        <MvcRazorExcludeRefAssembliesFromPublish>false</MvcRazorExcludeRefAssembliesFromPublish>
        <PreserveCompilationReferences>true</PreserveCompilationReferences>
      </PropertyGroup>
    
      <ItemGroup Condition="Exists('./openiddict.pfx')">
        <None Remove="openiddict.pfx" />
        <EmbeddedResource Include="openiddict.pfx">
          <CopyToOutputDirectory>Always</CopyToOutputDirectory>
        </EmbeddedResource>
      </ItemGroup>
    
      <ItemGroup>
        <Compile Remove="Logs\**" />
        <Content Remove="Logs\**" />
        <EmbeddedResource Remove="Logs\**" />
        <None Remove="Logs\**" />
      </ItemGroup>
    
      <ItemGroup>
        <Content Include="Pages\**\*.js">
          <CopyToOutputDirectory>Always</CopyToOutputDirectory>
        </Content>
        <Content Include="Pages\**\*.css">
          <CopyToOutputDirectory>Always</CopyToOutputDirectory>
        </Content>
      </ItemGroup>
    
      <ItemGroup>
        <Content Include="TextTemplates\**">
          <CopyToOutputDirectory>Always</CopyToOutputDirectory>
        </Content>
      </ItemGroup>
    
      <ItemGroup>
        <PackageReference Include="AspNet.Security.OAuth.LinkedIn" Version="8.1.0" />  
        <PackageReference Include="AspNetCore.HealthChecks.UI" Version="8.0.2" />
        <PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="8.0.1" />
        <PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="9.0.0.0" />
        <PackageReference Include="AspNetCore.HealthChecks.UI.InMemory.Storage" Version="8.0.1" />
        <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.0" />
        <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.0">
          <PrivateAssets>all</PrivateAssets>
          <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
        </PackageReference>
        <PackageReference Include="Serilog.AspNetCore" Version="8.0.2" />
        <PackageReference Include="Serilog.Sinks.Async" Version="2.0.0" />
        <PackageReference Include="Microsoft.AspNetCore.Authentication.Google" Version="9.0.0.0" />
        <PackageReference Include="Microsoft.AspNetCore.Authentication.MicrosoftAccount" Version="9.0.0.0" />
        <PackageReference Include="Microsoft.AspNetCore.Authentication.Twitter" Version="9.0.0.0" />
        <PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" Version="9.0.0.0" />
        <PackageReference Include="DistributedLock.Redis" Version="1.0.3" />
      </ItemGroup>
    
      <ItemGroup>
        <ProjectReference Include="..\Tapp.Application\Tapp.Application.csproj" />
        <ProjectReference Include="..\Tapp.HttpApi\Tapp.HttpApi.csproj" />
        <ProjectReference Include="..\Tapp.EntityFrameworkCore\Tapp.EntityFrameworkCore.csproj" />
      </ItemGroup>
    
      <ItemGroup>
        <PackageReference Include="Volo.Abp.Caching.StackExchangeRedis" Version="9.0.0" />
        <PackageReference Include="Volo.Abp.DistributedLocking" Version="9.0.0" />
        <PackageReference Include="Volo.Abp.Autofac" Version="9.0.0" />
        <PackageReference Include="Volo.Abp.AspNetCore.Serilog" Version="9.0.0" />
        <PackageReference Include="Volo.Abp.AspNetCore.Authentication.JwtBearer" Version="9.0.0" />
        <PackageReference Include="Volo.Abp.Swashbuckle" Version="9.0.0" />
        <PackageReference Include="Volo.Abp.FeatureManagement.Web" Version="9.0.0" />
      </ItemGroup>
    
      <ItemGroup>
        <PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.Theme.LeptonX" Version="4.0.0" />
      </ItemGroup>
    
      <ItemGroup>
        <PackageReference Include="Volo.Abp.Account.Pro.Admin.Web" Version="9.0.0" />
        <PackageReference Include="Volo.Abp.Account.Pro.Public.Web.OpenIddict" Version="9.0.0" />
        <PackageReference Include="Volo.Abp.Identity.Pro.Web" Version="9.0.0" />
        <PackageReference Include="Volo.Abp.AuditLogging.Web" Version="9.0.0" />
        <PackageReference Include="Volo.Abp.OpenIddict.Pro.Web" Version="9.0.0" />
        <PackageReference Include="Volo.Abp.LanguageManagement.Web" Version="9.0.0" />
        <PackageReference Include="Volo.Abp.TextTemplateManagement.Web" Version="9.0.0" />
        <PackageReference Include="Volo.Abp.TextTemplating.Razor" Version="9.0.0" />
        <PackageReference Include="Volo.Abp.Gdpr.Web" Version="9.0.0" />
        <PackageReference Include="Volo.CmsKit.Pro.Admin.Web" Version="9.0.0" />
      </ItemGroup>
    
      <ItemGroup>
        <PackageReference Include="Volo.Abp.Studio.Client.AspNetCore" Version="0.9.13" />
      </ItemGroup>
    
      <ItemGroup>
        <Content Update="Pages\Account\Components\ProfileManagementGroup\PersonalInfo\New.css">
          <ExcludeFromSingleFile>true</ExcludeFromSingleFile>
          <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
        </Content>
        <Content Update="Pages\DataHub\Index2.cshtml">
          <ExcludeFromSingleFile>true</ExcludeFromSingleFile>
          <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
        </Content>
      </ItemGroup>
    
    </Project>
    
    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    LiSong created

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Try to add template files as EmbeddedResource

      <ItemGroup>
        <Content Remove="TextTemplates\**" />
        <EmbeddedResource Include="TextTemplates\**" />
      </ItemGroup>
    

    https://abp.io/docs/latest/framework/infrastructure/virtual-file-system#working-with-the-embedded-files

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    LiSong created

    still the same error :(

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Please share a test project. You can upload it to https://wetransfer.com/ liming.ma@volosoft.com

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    LiSong created

    we changed it from scriban to razor engine, and it worked

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    ok. : )

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.8.0-preview. Updated on September 28, 2026, 11:44
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.