Open Closed

Could not find file '/Pages/Account/cregister.js' error while customizing Register page #8902


User avatar
0
ademaygun created

Hello,

I am currently working on customizing the MVC Register page in my ABP Framework project. I have added a custom JavaScript file named cregister.js to handle additional client-side logic. However, when I deploy the project, I encounter the following error:

Volo.Abp.AbpException: Could not find file '/Pages/Account/cregister.js'

  • I have created the cregister.js file and placed it in the /Pages/Account/ directory.

  • I have updated the Register.cshtml file to include the script bundle configuration as follows: @section scripts { <abp-script-bundle name="@typeof(Volo.Abp.Account.Public.Web.Pages.Account.RegisterModel).FullName"> <abp-script type="@typeof(ZxcvbnScriptContributor)"/> <abp-script src="/Pages/Account/PasswordComplexityIndicator.js"/> <abp-script src="/scripts/cregister.js"/> </abp-script-bundle> } }

  • I have also configured the bundle in the HttpApiHostModule.cs file as follows:

   Configure<AbpBundlingOptions>(options =>
    {
        options
            .ScriptBundles
            .Configure(typeof(RegisterModel).FullName, bundle => {
                bundle.AddFiles(
                    "/Pages/Account/cregister.js"
                );
            });
    });

Actually, according to this link, I shouldn't need a bundle configuration for a single file. I don't get any errors while debugging, but I get this error on the server?


8 Answer(s)
  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    Hi, please ensure that the related file (cregister.js) is an embedded resource (see https://abp.io/docs/9.0/framework/infrastructure/virtual-file-system#embedding-the-files).

    The related build action for the file should be embedded resource. (You can right-click to the file and see it's properties and check build-action)

  • User Avatar
    0
    ademaygun created

    Hi Engincan, I changed the Built Action property of the file to Embedded Resource but unfortunately I got the same error.

    I even tried something like this:

    1. Add textfile.txt as EmbeddedResource to the /Pages/Account folder (in Host project)
    2. Read the textfile.txt file in any an AppService method: var t = File.OpenText("/Pages/Account/textfile.txt"); But I still got the error: System.IO.DirectoryNotFoundException: Could not find a part of the path '/Pages/Account/textfile.txt'. I created the application via Abp Studio and did not make any special changes.
  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    Hi Engincan, I changed the Built Action property of the file to Embedded Resource but unfortunately I got the same error.

    I even tried something like this:

    1. Add textfile.txt as EmbeddedResource to the /Pages/Account folder (in Host project)
    2. Read the textfile.txt file in any an AppService method: var t = File.OpenText("/Pages/Account/textfile.txt"); But I still got the error: System.IO.DirectoryNotFoundException: Could not find a part of the path '/Pages/Account/textfile.txt'. I created the application via Abp Studio and did not make any special changes.

    Hi, it seems there is a misconfiguration for Virtual File System. If it's possible, please send your application via an email to support@abp.io with the ticket number, so I can fix it in your code and let you know about the problem, later on.

    Please let me know, when you send your solution via email or if you can't.

    Best regards.

  • User Avatar
    0
    ademaygun created

    Hi, I sent the sample application to support@abp.io

  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    Hi, I sent the sample application to support@abp.io

    Hi, thank you. I have downloaded your project and will write back asap.

  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    Hi, I have checked your project and it seems that you missed some configurations. In your project (where you defined the embedded resources), you should apply the following steps:

    1. Add Microsoft.Extensions.FileProviders.Embedded NuGet package to the project that contains the embedded resource(s).
    2. Add <GenerateEmbeddedFilesManifest>true</GenerateEmbeddedFilesManifest> into the <PropertyGroup>...</PropertyGroup> section of your .csproj file.

    Check the documentation for further info: https://abp.io/docs/9.0/framework/infrastructure/virtual-file-system#embedding-the-files

  • User Avatar
    0
    ademaygun created

    Hi Engincan, I missed that part in the document. Issue solved. Thank you very much for your support.

  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    Hi Engincan, I missed that part in the document. Issue solved. Thank you very much for your support.

    Hi, great to hear that, thanks.

    Regards.

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
Do you need assistance from an ABP expert?
Schedule a Meeting
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v9.2.0-preview. Updated on March 19, 2025, 10:09