Questa pagina non è ancora tradotta in italiano: qui la trovi in inglese.
Scan your pages
Write the manifest of your Blazor pages with Novior.MentorAgent.Scanner at development time, or with novior-mentor scan in a pipeline.
In questa pagina
Use this page to write the manifest of your pages: the file that says which fields, selects, buttons and links each page of your Blazor application offers. Without it, MentorAgent knows only the routes of your pages, as Pages the agent knows explains. A scan opens each page in the Edge or Chrome that is already installed on your machine, with no window on the screen, and writes what it found to mentor-ui-manifest.json in your project. The next build embeds that file in the application. Then GetPages() gives each page of the manifest with the coverage Scanned, and with its elements.
In 1.5.0 the manifest and the list of pages are for you and for the tools that read the catalog of your application. The model does not receive them. To let the agent open a page with navigate_to, describe the page with [MentorPage].
There are two ways to scan:
- At development time, with the package
Novior.MentorAgent.Scannerinside your application. The scan runs each time you start the application inDevelopment. - From outside the application, with the .NET tool
novior-mentor scanofNovior.MentorAgent.Cli. Use it in a pipeline, or for a WebAssembly standalone application, where the scanner cannot run inside the app.
Before you start
Section titled “Before you start”- The AutoMentor is on. The scan reads the pages that MentorAgent knows from your routes, so set
AutoMentor.Enabled. - Edge or Chrome is installed. The scan uses the browser that is already on the machine and never downloads one. With none, it does not start, and the log says why. Set
BrowserPathfor a browser in another place.
Add the scanner
Section titled “Add the scanner”Reference the package in Debug only, so that it never reaches a Release build:
<PackageReference Include="Novior.MentorAgent.Scanner" Version="1.5.0"
Condition="'$(Configuration)' == 'Debug'" />Then register it under #if DEBUG, next to AddMentorAgent:
builder.Services.AddMentorAgent(options =>
{
options.AppName = "Billing";
options.ChatClient = chatClient;
options.ScanAssemblies = [typeof(Program).Assembly];
options.AutoMentor.Enabled = true; // the pages and their manifest
});
#if DEBUG
builder.Services.AddMentorUiScanner(options =>
{
options.Roles = ["Manager"];
options.RouteParameters["/invoices/{id}"] =
new Dictionary<string, string> { ["id"] = "1" };
});
#endifRoles and RouteParameters are explained below. Without them, AddMentorUiScanner() reads, with no user, every page that it can open without a value: see Pages with route parameters.
Run the scan
Section titled “Run the scan”Start the application in Development, with dotnet run or from your editor. Once the application has started, the scan runs in the background. It never stops the application, and outside Development it does nothing. The log says what it does:
AutoMentor: 5 page(s) from the routes of the application.Scanning 5 page(s) of http://127.0.0.1:51262/ with msedge.exe, with no user and as Manager; 0 unchanged since the last scan.The scan read 5 page(s) and kept 0: 5 page(s), 4 element(s), 4 left out, with 0 safe click(s); manifest written to …
The last line says how many pages the scan read again, and how many it kept unchanged from the last scan. Then it says what the manifest holds: its pages, its elements and the elements left out, and how many safe clicks the scan made.
The scan writes mentor-ui-manifest.json in the project of the application. Commit the file. The next build embeds it in the application, also when the project references only Novior.MentorAgent.Server. The build does not publish it as a separate file. To write it to another path, set the MSBuild property <MentorUiManifest> in the project.
For a page with a search field and a select, the manifest says this:
{
"route": "/invoices",
"scannedAt": "2026-11-26T14:58:25+00:00",
"elements": [
{
"element": "input",
"label": "Search invoices",
"type": "search",
"selector": "#invoice-search"
},
{
"element": "select",
"label": "Status",
"options": [ "Open", "Paid" ],
"selector": "#invoice-status"
}
]
}The labels of the options are there, never their values, and never what a field holds. A page that the scan cannot read is left out, and the log names it.
Pages with route parameters
Section titled “Pages with route parameters”A page whose route has parameters, such as /invoices/{id:int}, is opened only with a value for each parameter. Give the values in RouteParameters, as in the code above, or in the configuration, in the section MentorAgent:Scanner:
{
"MentorAgent": {
"Scanner": {
"RouteParameters": { "/invoices/{id}": { "id": "1" } }
}
}
}The key is the route with only the name of each parameter: /invoices/{id} for /invoices/{id:int}, because a configuration key cannot hold the colon of a constraint. Then:
- each value is escaped, and stays one segment of the page's path;
- a parameter with no value takes its default value, and an optional parameter is left out;
- otherwise the page is not opened: it stays
ToScan, and the log names it.
The manifest has the page under its route, as the router writes it.
Scan as a role
Section titled “Scan as a role”A page can show more to a manager than to a guest. With Roles, the scan reads every page with no user first, then once for each role, as a user of its own that has that role alone. An element seen with no user needs no role in the manifest. An element seen only by some roles has those roles.
The scan signs in its own user with a one-time token. The token stays in memory, and the scan sends it from this machine only, to /_mentor/scan/start. That endpoint accepts it only from the loopback address, and it is not mapped outside Development. The session cookie that the endpoint gives stops working after each pass and when the scan ends. A page that sends the scan's user to another address is not read for that user.
Only the pages that changed
Section titled “Only the pages that changed”The scan keeps a fingerprint of each page in obj/mentor-ui-scan.state.json, never in the manifest: a value that changes when the code of the page or of its layouts changes. The next scan reads again only the pages whose fingerprint changed, and the pages that the manifest does not have. It writes the manifest only when its content changes, so a scan does not start another build under dotnet watch. With nothing to read, no browser starts.
A component that a page renders is not part of its fingerprint. After you change one, set Full = true, or delete obj/mentor-ui-scan.state.json, and the next scan reads every page again.
What the scan clicks
Section titled “What the scan clicks”To read what is behind a tab, a menu or a collapsed section, the scan clicks only where the page says that something opens: role="tab", a menu button (aria-haspopup), aria-expanded="false" and <summary>. It clicks at most 20 times per page, and reads the page again after each click.
It never clicks:
- a submit button, or a button of a form that posts;
- a link to another page;
- a hidden or disabled element;
- MentorAgent's chat widget;
- an element whose label, title, name or id says delete, save, pay, send, confirm or a similar word.
While it clicks, the page submits no form, opens no window, and confirm() answers no. A click still runs the code of your application: mark with data-mentor-scan="skip" anything that must not be clicked.
What never goes in the manifest
Section titled “What never goes in the manifest”- No value. The scan never reads what an input, a text area or an editable element holds. The format has no place for a value.
- Fields left out. A password field, a field of card data (
autocomplete="cc-…"), a hidden or disabled element, and MentorAgent's own chat widget. - Zones left out. Nothing inside an element marked
data-mentor-excludeis read.
When the application starts, MentorAgent does not trust the manifest: it drops these elements again, whoever wrote the file. A label is text of your page, so the code that reads it treats it as data, never as an instruction.
.NET MAUI Blazor Hybrid
Section titled “.NET MAUI Blazor Hybrid”In a .NET MAUI Blazor Hybrid app on Windows, no web host starts the scan, so you start it yourself. Register the scanner as above, then start the scan on app.Services, right after builder.Build() and before the window of the app is created:
#if DEBUG
services.StartMentorUiScan(); // MAUI: no host starts the scan
#endifIt runs in a Debug build of the app only. It opens the DevTools port of the app's WebView2 on the loopback, and the log names the port and the page that it found. Then it reads each page in the window of the app, where you see the pages change. At the end, it goes back to the page that it found at the start.
- The app's own user. The scan clicks as the user of the app, with no user of its own, so
Rolesis not used and the manifest has no roles. Use it only with a build that points to development data. - Windows only, because it needs the WebView2. The DevTools port stays open on the loopback until the app closes.
React and Angular
Section titled “React and Angular”Use this setup for a React or Angular front end that its own server serves, such as the development server of Vite or of the Angular CLI. Register the scanner in the .NET backend, and give it the address of the front end:
{
"MentorAgent": {
"Scanner": {
"FrontEndUrl": "http://localhost:5173/",
"FrontEndRoutes": [ "/invoices", "/invoices/:id" ],
"RouteParameters": { "/invoices/{id}": { "id": "1" } }
}
}
}The scan then reads the pages of the front end instead of the pages of the host:
With
FrontEndRoutes, it opens those routes, as the router writes them.:idis opened with the value of/invoices/{id}inRouteParameters, and a catch-all (*,**) is never opened.Without
FrontEndRoutes, it follows the links of the front end from its first page: links of its own origin, without query or fragment, and none insidedata-mentor-exclude.No user. The scan's user signs in to the .NET host only, so it reads the front end with no user, and
Rolesis not used.Every page, every time. No code of the host says whether a page of the front end changed, so the scan reads each page at every scan.
In a pipeline
Section titled “In a pipeline”novior-mentor scan runs the same scan from outside the application, and writes the same manifest:
- Use it in a pipeline that tests your application, or for a WebAssembly standalone application.
- The pages come from the built DLL of the application.
- The application runs at
--url, for example a test environment or the development server of a WebAssembly app. - The browser runs on the machine that runs the command, never on the server of the application.
Install the tool, then run the scan:
dotnet tool install --global Novior.MentorAgent.Cli --version 1.5.0
novior-mentor scan --url https://test.example.com \
--project src/Billing/Billing.csproj \
--account Manager=SCAN_MANAGER_COOKIE --fail-on-change| Option | What it does |
|---|---|
--url | The address of the running application, http or https. Only its origin is kept |
--project | The project of the application: the pages come from its newest build in bin |
--assembly | The built dll of the application, instead of --project |
--manifest | Where to write the manifest. By default, next to the project |
--account <role>=<variable> | An account of your team that has that role alone. The environment variable holds its session cookie, name=value |
--parameters <file.json> | The route parameters, in the shape of RouteParameters |
--full | Reads every page again, as Full |
--fail-on-change | Reads every page and writes nothing. When the manifest would change, it names the pages and exits with 3 |
The command exits with 0 when the scan is done, 1 when the scan could not run, 2 when the command line is wrong, and 3 when the manifest would change.
- The cookie is a secret. Keep the variable of
--accountamong the secrets of your pipeline. The cookie is set for the address of the application only, and never written to the log. A variable that is missing or empty stops the command before anything is scanned. - Keep the manifest up to date. With
--fail-on-changein your pipeline, a change to a page that the committed manifest does not describe fails the build. Run the scan, and commit the manifest that it writes. - A test environment, never real data. The scan clicks with the accounts that you give it. To read the pages, it loads the DLL of your application, and loading it runs the constructors of its attributes: your own code, in your own pipeline.
Options
Section titled “Options”The scanner's options, a MentorUiScannerOptions. Set them in AddMentorUiScanner, or in the configuration section MentorAgent:Scanner.
| Option | Default | What it does |
|---|---|---|
BrowserPath | null | The full path to Edge or Chrome. null takes the first one installed |
ManifestPath | null | Where to write the manifest. null is the project's mentor-ui-manifest.json, or the file of <MentorUiManifest> |
PageTimeout | 15 seconds | How long the scan waits for a page to load and settle |
Roles | Empty | The roles to scan as, each as a user of its own |
RouteParameters | Empty | The values of the route parameters, by route |
Full | false | Reads every page again, not only those that changed |
FrontEndUrl | null | The address of a React or Angular front end to scan instead of the host |
FrontEndRoutes | Empty | The routes of that front end. Empty follows its links |
Safety
Section titled “Safety”- The DevTools port. While the scan runs, the browser's DevTools port is open on the loopback, and a program running on this machine could connect to it. The port closes when the scan ends, and the browser's profile, in a temporary folder, is deleted.
- An application stopped by force. On Windows the browser runs in a job object, a Windows feature that ties it to the application, and closes with the application, also when the debugger stops it. On Linux and macOS, the browser and its port stay open until the next scan starts, which closes them, or until you close the browser.
- Paths in the assembly. In Debug, the package writes the absolute paths of the manifest and of the state file into the assembly of the application. This is one more reason to reference it in Debug only.
Limits
Section titled “Limits”- One level of clicks. A menu inside a menu that the scan opened is not opened.
- A menu without its attributes. An element inside a menu with neither
aria-expandednoraria-haspopupis not drawn on the page until someone opens it, so it stays out of the manifest. - The pages that your users open in production are not scanned. With the AutoMentor on, the widget can observe them: see Pages observed in production.
Vedi anche
Sezione “Vedi anche”- Pages the agent knows — With the AutoMentor on, MentorAgent knows the pages of your Blazor app from their routes, and what a scan or your users saw of each one.
- Configuration options — Every MentorOptions property with its type, default and effect, grouped by area, plus the options of the WebAssembly client and the YAML loader.
- MentorUiScannerOptions class — Story 1636 — the options of the scan of the pages, set with MentorUiScannerExtensions.AddMentorUiScanner or from the configuration section MentorAgent:Scanner.
- MentorAgent 1.5.0 release notes — What's new in MentorAgent 1.5.0: pages known from your routes, a scan of the pages, recipes, forms and grids as UI actions, and the cost per agent and user.
