Add page and generated code

i create a folder and in the folder i create a page. the generated page code has the same class name as a page already in the application and so the application will not build.

when generating a new page have an option to name the code for the page using the folder name as part of the namespace so that the new page in a folder has a name that does not clash with pages created in other folders.

i may be generating crud pages for ef but i may need to keep the default crud pages in the other folder.

Hi @figuerres,

We will address that with the next release. The directory name will be part of the namespace of the codebehind.

thanks, there are some other items that i have been trying to figure out if its me and how i am trying to use the tools or defects.
like if i used blazor studio to create a page it seems like the project security options are not added to the new page.

also i see that the older radzen code generator and the new blazor studio generator create different styles of code. the old radzen tool creates 3 files a razor page and two code files.
the new one creates 2 files.

i am working on a new project that will have possibly over 50 tables to build ui for some i am trying to work out how to get the best from the tools.

many related tables and a need to mix and match grids and forms..... enterprise lob app.

They should be. Adding a new page when security is enabled should inject the security service and add @attribute [Authorize].

This is by design. A third file is no longer needed. This and the other differences are documented here: Differences from Radzen | Radzen Blazor Studio

with the new update i now see that the created folder name is now part of the code namespace.
but the classes / pages as generated have issues with the routing engine.

example of the error i get:

InvalidOperationException: The following routes are ambiguous:
'edit-plan' in 'Test.Pages.PlansMain.EditPlan'
'edit-plan' in 'Test.Pages.EditPlan'
Microsoft.AspNetCore.Components.RouteTableFactory.RouteComparison(RouteEntry x, RouteEntry y)

InvalidOperationException: Failed to compare two elements in the array.
System.Collections.Generic.ArraySortHelper<T>.Sort(Span<T> keys, IComparer<T> comparer)

for example i have a table called contact, i let the scaffolding create default pages so it creates contacts.razor and addcontact.razor and editcontact.razor
now i create a folder named test.
now i create a page in test that scaffolds the table contacts

now i have the code and pages in the new folder but the routes for them are the same as the routes for the default and the server cant cope with having two routes named editcontact

not that i want to have lots of duplicate pages, i am trying to use the scaffolding to help me work out the right code for a form that i will edit to get to the final version.....
and when i solve that i will delete some pages that i will not have the final app using.

that aside i think that when pages are added that the generator should create routes that also use the page / namespace to separate the routes and the classes so that they are each valid.

so we get for example

EditContact.razor with @page "edit-contact"
and
/pages/test/EditContact.razor with @page "/test/edit-contact"
and main navigation can also provide the menu items that match the routes to the pages....

We may implement that in a future release.

1 Like