14 Answer(s)
-
0
- Solution The error “Cannot read properties of undefined (reading 'KSVR')” means the dynamic JavaScript proxy object for your module/remote-service name is not being created on the page. In ABP MVC/Razor Pages (v10), these proxies appear under window.<rootNamespace>.<remoteServiceName> (e.g., window.webCMS.KSVR.services...) only when:
- the dynamic proxy script is enabled and loaded on the page,
- the remote service/app service is exposed (controller has [RemoteService] enabled),
- the HttpApi (or HttpApi.Host in tiered) is reachable for proxy discovery,
- the name you use in JS matches your actual RootNamespace and RemoteService name.
Verify and fix with the checklist below.
A) Ensure dynamic JS proxy is enabled
- In your Web (UI) module, check ConfigureServices:
Configure<AbpAspNetCoreMvcOptions>(options => { options.ConventionalControllers.Create(typeof(KSVRApplicationModule).Assembly); }); Configure<AbpAspNetCoreMvcClientProxyOptions>(options => { // default is dynamic proxies ON; ensure not disabled globally // options.DisableAbpDynamicProxyScript = false; // only if you had set it true somewhere });- If you previously disabled dynamic proxies, remove that config or set it back to enabled.
B) Load the dynamic proxy script on the page
- In Razor Pages layout (Pages/_Layout.cshtml) or the specific page, include the ABP dynamic proxy bundle AFTER abp.js and before your page’s index.js:
<script src="~/Abp/ApplicationConfigurationScript"></script> <script src="~/Abp/ServiceProxyScript"></script> <script src="~/libs/jquery/jquery.js"></script> <script src="~/libs/bootstrap/js/bootstrap.bundle.min.js"></script> <!-- ... other abp libs --> <script src="~/Pages/BangGiaVeNgays/index.js"></script>- Make sure index.js runs after ServiceProxyScript; otherwise window.<rootNamespace>.* will be undefined.
C) Confirm correct Root Namespace in JS
- Find your solution’s Root Namespace (e.g., WebCMS). The dynamic object path is: window.<rootNamespace>.<remoteServiceName>.services.<moduleOrGroup>.<service>
- In your screenshot, you use:
var bangGiaVeNgayService = window.webCMS.KSVR.services.bangGiaVeNgays.bangGiaVeNgays;This will only work if:
- Root namespace is webCMS (case sensitive: it should match the C# root namespace; typically PascalCase, e.g., WebCMS).
- RemoteServiceName is “KSVR” on the controller/service.
- If your root namespace is “KSVR” or “WebCMS” with different casing, fix the path accordingly, e.g.:
- window.WebCMS.KSVR.services...
- or window.KSVR.Default.services... (if remote service name is Default)
D) Ensure your AppService is exposed to HTTP (so proxy can be generated)
- Your Application Service must be discoverable by controller generation and marked as remote service:
[RemoteService(true)] public class BangGiaVeNgayAppService : ApplicationService, IBangGiaVeNgayAppService { // ... }- Or on the assembly/module, you already configure ConventionalControllers.Create; ensure the assembly containing the controller is passed.
E) If it’s a tiered setup (Auth Server separated)
- The Web (UI) app must be able to fetch proxy metadata from the HttpApi.Host (or Gateway). Configure RemoteServices in appsettings.json of the Web project so the dynamic proxy script knows where to reach:
"RemoteServices": { "Default": { "BaseUrl": "https://localhost:443xx" // your HttpApi.Host } }- If your remote service name is “KSVR” (not Default), configure its endpoint too (or ensure it maps to the Default remote):
"RemoteServices": { "Default": { "BaseUrl": "https://localhost:443xx" }, "KSVR": { "BaseUrl": "https://localhost:443xx" } }- Run the HttpApi.Host and confirm it’s reachable from the browser (no CORS/ auth issues) so ServiceProxyScript can be built.
F) Confirm the final JS object path
- Open the browser console after the page loads and run:
- Object.keys(window)
- window.WebCMS or window.webCMS (check which exists)
- window.WebCMS.KSVR or window.WebCMS.Default
- Expand to services.* to see the generated services and exact names.
- Correct your index.js to the real, existing path and pay attention to name pluralization (Suite usually generates plural group names, e.g., bangGiaVeNgays).
G) Common pitfalls to fix
- Wrong casing of root namespace in JS (use the exact C# root namespace as created by your solution).
- Not loading ServiceProxyScript before your page script.
- AppService not included in conventional controller generation (wrong assembly).
- RemoteServiceName mismatch (JS uses KSVR but server uses Default, or vice versa).
- In a tiered solution, RemoteServices BaseUrl not set or HttpApi.Host not running.
- If you switched to static JS proxies, you must serve the generated static file; but Suite’s Razor Pages use dynamic proxies by default—keep them enabled for simplicity.
Once the above are corrected, the line like below should work without error:
var l = abp.localization.getResource('KSVR'); var bangGiaVeNgayService = window.WebCMS.KSVR.services.bangGiaVeNgays.bangGiaVeNgays; bangGiaVeNgayService.getList({ filter: '...' }).then(res => { // ... });- Sources
- https://abp.io/docs/latest/framework/ui/mvc-razor-pages/javascript-api/
- https://abp.io/support/questions/7434
- https://abp.io/support/questions/8751
This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.
-
0
-
0
hi
Can you enter
window.webCMSin the browser console to check how many namespaces it contains?Thanks,.
-
0
-
0
hi
Can you share the steps to reproduce it? Or share a project?
liming.ma@volosoft.com
Thanks.
-
0
[maliming] said: hi
Can you share the steps to reproduce it? Or share a project?
liming.ma@volosoft.com
Thanks.
I used ABP Suite to automatically generate the entity (my project is using MVC Razor Pages), but when I run the website, I get the error shown in the image.
-
0
ok, can you share your project?
Thanks.
-
0
[maliming] said: ok, can you share your project?
Thanks.
Can you support me via TeamViewer?
-
0
hi
Please use Zoom client join and share your screen
https://us05web.zoom.us/j/89617058236?pwd=Yxc0jPwQV4W4tLwYyQNnNO00Y0lBIo.1 Thanks
-
0
[maliming] said: hi
Please use Zoom client join and share your screen
https://us05web.zoom.us/j/89617058236?pwd=Yxc0jPwQV4W4tLwYyQNnNO00Y0lBIo.1 Thanks
-
0
hi
Please generate the static proxy files in your web project.
Then you will see the script in webproject/abp/serviceproxyscript endpoint.
See https://abp.io/docs/latest/guides/add-module-to-microservice#using-the-static-proxy https://abp.io/docs/latest/framework/api-development/static-csharp-clients#code-generation
-
0
[maliming] said: hi
Please generate the static proxy files in your web project.
Then you will see the script in webproject/abp/serviceproxyscript endpoint.
See https://abp.io/docs/latest/guides/add-module-to-microservice#using-the-static-proxy https://abp.io/docs/latest/framework/api-development/static-csharp-clients#code-generation
ok thank, i will try
-
0
ok
-
0
https://abp.io/support/questions/10199/Static-JavaScript-API-Client-Proxies#answer-3a1e1d87-5737-6e5f-b211-58292bc86e5f



