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)
-
0
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)
-
0
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:
- Add textfile.txt as EmbeddedResource to the /Pages/Account folder (in Host project)
- 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.
-
0
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:
- Add textfile.txt as EmbeddedResource to the /Pages/Account folder (in Host project)
- 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.
-
0
Hi, I sent the sample application to support@abp.io
-
0
Hi, I sent the sample application to support@abp.io
Hi, thank you. I have downloaded your project and will write back asap.
-
0
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:
- Add
Microsoft.Extensions.FileProviders.Embedded
NuGet package to the project that contains the embedded resource(s). - 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
- Add
-
0
Hi Engincan, I missed that part in the document. Issue solved. Thank you very much for your support.
-
0
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.