-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Improve Blazor project template #52234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4bda6b1
Add Program.Main.cs
halter73 80683ae
Remove unnecessary "@"'s
halter73 93a3b7c
Add AccessDenied page
halter73 b5c4078
Remove unnecessary "@"'s from Routes.razor
halter73 d7f366d
Always use typeof(ProjectName.Client._Imports)
halter73 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...tes/Web.ProjectTemplates/content/BlazorWeb-CSharp/BlazorWeb-CSharp.Client/Program.Main.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#if (IndividualLocalAuth) | ||
using BlazorWeb_CSharp.Client; | ||
using Microsoft.AspNetCore.Components.Authorization; | ||
#endif | ||
using Microsoft.AspNetCore.Components.WebAssembly.Hosting; | ||
|
||
namespace BlazorWeb_CSharp.Client; | ||
|
||
class Program | ||
{ | ||
static async Task Main(string[] args) | ||
{ | ||
var builder = WebAssemblyHostBuilder.CreateDefault(args); | ||
|
||
#if (IndividualLocalAuth) | ||
builder.Services.AddAuthorizationCore(); | ||
builder.Services.AddCascadingAuthenticationState(); | ||
builder.Services.AddSingleton<AuthenticationStateProvider, PersistentAuthenticationStateProvider>(); | ||
|
||
#endif | ||
await builder.Build().RunAsync(); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...tes/content/BlazorWeb-CSharp/BlazorWeb-CSharp/Components/Account/Pages/AccessDenied.razor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
@page "/Account/AccessDenied" | ||
|
||
<PageTitle>Access denied</PageTitle> | ||
|
||
<header> | ||
<h1 class="text-danger">Access denied</h1> | ||
<p class="text-danger">You do not have access to this resource.</p> | ||
</header> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unlike the server template, this does not have an accessibility modifier. Neither does the
Main
method. I would have made both the class andpublic
like we do for the server project, but this made the@typeof(Program).Assembly
reference in Routes.razor ambiguous.aspnetcore/src/ProjectTemplates/Web.ProjectTemplates/content/BlazorWeb-CSharp/BlazorWeb-CSharp/Components/Routes.razor
Line 5 in d8acc61
I could change that to be
@typeof(BlazorWeb_CSharp.Program).Assembly
instead and make this public. And then only qualify it when you've disabled top level statements.Does anyone prefer that, or is everyone fine the way it is?