dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.36k stars 9.99k forks source link

[Preview 8] Blazor (Server Side)overriding identity via scaffolding throws error #13120

Closed hasmMarques closed 4 years ago

hasmMarques commented 5 years ago

dotnet 3.0.100-preview8-013656

  1. Upgrade to .net core 3.0.100-preview8-013656
  2. Create a new asp.net core web application project, select server side blazor.
  3. Change Identity to individual user account
  4. After project creation right click Areas/Identity folder, Add New Scaffold Item, Override all files throws error.

image

snmigerl commented 5 years ago

Same Problem here...

mkArtakMSFT commented 5 years ago

Thanks for contacting us @hasmMarques. @vijayrkn should this move to the scaffolding repo?

vijayrkn commented 5 years ago

@HaoK - do you want to handle identity content issues in aspnet/identity or aspnet/scaffolding?

HaoK commented 5 years ago

Ideally it should be based on which repo the fix is going into, if it requires changes in both the framework UI library as well as the scaffolding, it should be in AspNetCore, if its only changes required in the scaffolding/templates, then it should go in the scaffolding repo.

HaoK commented 5 years ago

Either way if its assigned to me I will see it

etcircle commented 5 years ago

I have a similar issue when I tried to scaffold through dotnet CLI using VS Code. I wasn't able to start the project with the scaffolded items. I wanted to use them to make a custom login and register forms with Blazor (Razor) components without success. I tried to start a new project without identity and manually to configure it, but with server-side I awlays ended with the error below. It happens when I hit _signInManager.SignInAsync in the debugger. Similar if not the same happens with the .PasswordSignInAsync method.

Microsoft.AspNetCore.Components.Server.ComponentHub: Warning: Unhandled exception in circuit CfDJ8Hh6jTIGeEREjBREH96LvZgUyKAbXakcJAYLhWVqy470uzfvlak5-mijm83-dd8INRiOUBUTpC_s8bfFOqj_TRO5kxUTfjwwJ_huMKg5n1Colx8a7I9ZxRiigfJ_tsDWyOglxjwcw_2QYtkz4ZI1BVuNrRk5QO-VzwSYKLuQU4lI

System.InvalidOperationException: OnStarting cannot be set because the response has already started.
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ThrowResponseAlreadyStartedException(String value)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.OnStarting(Func`2 callback, Object state)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.Microsoft.AspNetCore.Http.Features.IHttpResponseFeature.OnStarting(Func`2 callback, Object state)
   at Microsoft.AspNetCore.Http.DefaultHttpResponse.OnStarting(Func`2 callback, Object state)
   at Microsoft.AspNetCore.Http.HttpResponse.OnStarting(Func`1 callback)
   at Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationHandler.InitializeHandlerAsync()
   at Microsoft.AspNetCore.Authentication.AuthenticationHandler`1.InitializeAsync(AuthenticationScheme scheme, HttpContext context)
   at Microsoft.AspNetCore.Authentication.AuthenticationHandlerProvider.GetHandlerAsync(HttpContext context, String authenticationScheme)
   at Microsoft.AspNetCore.Authentication.AuthenticationService.SignInAsync(HttpContext context, String scheme, ClaimsPrincipal principal, AuthenticationProperties properties)
   at Microsoft.AspNetCore.Identity.SignInManager`1.SignInWithClaimsAsync(TUser user, AuthenticationProperties authenticationProperties, IEnumerable`1 additionalClaims)
   at Microsoft.AspNetCore.Identity.SignInManager`1.SignInOrTwoFactorAsync(TUser user, Boolean isPersistent, String loginProvider, Boolean bypassTwoFactor)
   at Microsoft.AspNetCore.Identity.SignInManager`1.PasswordSignInAsync(TUser user, String password, Boolean isPersistent, Boolean lockoutOnFailure)
   at Microsoft.AspNetCore.Identity.SignInManager`1.PasswordSignInAsync(String userName, String password, Boolean isPersistent, Boolean lockoutOnFailure)
   at Experimental.Pages.Security.Login.HandleLogin() in /Users/codingaccountant/CodingAccountant/Experimental/Pages/Security/Login.razor:line 44
   at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
   at Microsoft.AspNetCore.Components.Forms.EditForm.HandleSubmitAsync()
   at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
   at Microsoft.AspNetCore.Components.Rendering.Renderer.GetErrorHandledTask(Task taskToHandle)
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1]
      Executed endpoint '/_blazor'
Microsoft.AspNetCore.Routing.EndpointMiddleware: Information: Executed endpoint '/_blazor'
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
      Request finished in 28923.267200000002ms 101 
Microsoft.AspNetCore.Hosting.Diagnostics: Information: Request finished in 28923.267200000002ms 101 
koskila commented 5 years ago

Ran into exactly the same issue as @hasmMarques.

mkArtakMSFT commented 5 years ago

@vijayrkn, @HaoK what's the latest on this? Can you provide an ETA for resolution on this?

HaoK commented 5 years ago

I'm OOF this week, I can take a look and provide an ETA on monday

HaoK commented 5 years ago

@vijayrkn any ideas on what's going on here? The scaffold operation does not complete successfully due to the Startup error above, the App itself compiles fine, so something is broken on the scaffolding operation I guess?

Note: its not necessary to override all files either, even just overriding a single UI file will result in this error, so I think its something wrt to compilation of the app during the scaffolding process

vijayrkn commented 5 years ago

If it is an issue with scaffolding operation, you can remove the preview9 milestone. This would be fix on the VS side then.

Gpd1969 commented 5 years ago

Similar issue,

ErrorApp0004

ErrorApp0002

ErrorApp0001

henk787 commented 5 years ago

I have posted a work-around for this problem on SO recently.

The steps, based on a Preview8 server-side project with "Individual user accounts" :

snmigerl commented 5 years ago

That works! Thanks!

rksatheesh commented 5 years ago

Hi Henk,

Thanks for the input. its works fine however there is a bit confusion. there are two _viewStart.cshtml which one should i delete. i tried both , but both time i am getting two headers. as i attached with this thread. TwoLayout

Looking for your support.

henk787 commented 5 years ago

You should not delete the one under \Areas\Identity, just the one under the top level \Pages.

So it should have worked, make sure you have a Build with no errors, flush your browser (Ctrl+F5) etc.

henk787 commented 5 years ago

Just to update this for Preview9 and RC1, only 2 steps remain:

after the add-scaffolding,