Open Closed

VirtualFileSystem not working in deployed application to IIS #4673


User avatar
0
AdamMusson created

If you're creating a bug/problem report, please include followings:

  • ABP Framework version: v7.0.1
  • UI type: MVC
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): No
  • Exception message and stack trace: Could not find a file/folder at the location: /Templates/ConfirmEmail.cshtml
  • Steps to reproduce the issue: I have followed steps in articles for overriding the registermodel with a custom one that has some steps for my application's registration. The EmailTemplate for the ConfirmEmail is located in the Templates directory in the DomainModule project. The system sends the email and everything works fine locally but when it is deployed to IIS the VirtualFileSystem is not picking up the /Templates/ConfirmEmail.cshtml even though it is an embedded resource.

I have this code in the WebModule to configure the VirtualFIleSystem

 private void ConfigureVirtualFileSystem(IWebHostEnvironment hostingEnvironment)
    {
        Configure<AbpVirtualFileSystemOptions>(options =>
        {
            options.FileSets.AddEmbedded<HourcoinWebModule>();
            options.FileSets.AddEmbedded<HourcoinDomainModule>(
                 baseNamespace: "Hourcoin.Templates",
                 baseFolder: "/Templates");

            options.FileSets.AddEmbedded<RegistrationDomainModule>();
            


            if (hostingEnvironment.IsDevelopment())
            {

                options.FileSets.ReplaceEmbeddedByPhysical<HourcoinDomainSharedModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}Hourcoin.Domain.Shared", Path.DirectorySeparatorChar)));
                options.FileSets.ReplaceEmbeddedByPhysical<HourcoinDomainModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}Hourcoin.Domain", Path.DirectorySeparatorChar)));
                options.FileSets.ReplaceEmbeddedByPhysical<HourcoinApplicationContractsModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}Hourcoin.Application.Contracts", Path.DirectorySeparatorChar)));
                options.FileSets.ReplaceEmbeddedByPhysical<HourcoinApplicationModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}Hourcoin.Application", Path.DirectorySeparatorChar)));
                options.FileSets.ReplaceEmbeddedByPhysical<HourcoinHttpApiModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}Hourcoin.HttpApi", Path.DirectorySeparatorChar)));
                options.FileSets.ReplaceEmbeddedByPhysical<HourcoinWebModule>(hostingEnvironment.ContentRootPath);
            }
        });
    }

This works in development as the Physical File is used using the above ReplaceEmbeddedByPhysical. When deployed to IIS at myasp.net the email is not working because the template is not being rendered. I have caught the error and displayed it in the following screenshot image.

I have made sure the files in the Templates directory are Embedded Resources.

What could I be missing? Any help or suggestions would be appreciated .as i have followed all the documentation I can find and have not had any luck. I keep getting the error even after specifically ensuring the environment is Production in the web.c onfig which shouldn't be necessary. Is there a bug in the VirtualFIleSystem?


2 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team

    hi

    Can you reproduce this in the template project and share it with me? liming.ma@volosoft.com

  • User Avatar
    0
    AdamMusson created

    Hi, I have shared a demo project Github repository with you so you can see a project based on the template project illustrating the problem. The code connects to the same database that has been deployed to myasp.net and as you can see works in Debug on the local machine.

    http://vfsdemo-001-site1.btempurl.com/ Is the Url you can see the code is deployed to. When you run it here and try to register the registration will fail because the ConfirmEmail template can't be found.

    On localhost the code works because of the ReplaceEmbeddedAsPhysical. On the deployed version it doesn't work because the EmbeddedFiles aren't being found in the virtualfilesyste,.

    Everything else is the same as both the local and deployed code are pointing to the same database. Any help in what I have done wrong here, if it isn't a bugm, would be helpful.

    Let me know if you need anything else. Thanks

Made with ❤️ on ABP v8.3.0-preview Updated on July 01, 2024, 12:03