AlvinfromDiaspar
AlvinfromDiaspar

Reputation: 6814

Blazor /Pages folder required for all pages/views?

Using the default Blazor helloworl app, i copied the FetchData.razor page to a separate, custom folder.

The result:

The page is not being rendered properly (the page is taking up the whole screen / the navigation menu is gone).

Question:

Do blazor pages/views must be in the /Pages folder?

Upvotes: 2

Views: 2247

Answers (1)

Chris Sainty
Chris Sainty

Reputation: 8521

You are free to put components in whatever folders you wish, the Pages folder is just what comes with the template. But you will notice in the default templates, the Pages folder has a file called _Imports.razor which contains the following:

@layout MainLayout

This means all components in the Pages folder automatically get the MainLayout applied. If you've moved your component to another folder you will need to either copy the above line to your component or copy the _Imports.razor into your new directory.

Upvotes: 3

Related Questions