An unhandled exception occurred while processing the request. InvalidOperationException: This endpoint is not expected to be executed directly.

1 mese tempo fa
Dont know what has happened - I cannot run any version of 4.5  in Visual Studio
Keep getting this error - tried downloading a new fresh version of 4.5.4 with no result
Does not matter if running in IIS or localhost
Website runs up but then click any link on the page i.e. Login or anything and this error occurs
Sometimes it responds and works ok if you stop start IIS and/or App pool
But does not always work - and then when it does work the error is back next time you stop debugging. Search google find nothing.
Dont know if it is as a result of a new version of VS or what has gone wrong :(((

System.InvalidOperationException: This endpoint is not expected to be executed directly.
   at Microsoft.AspNetCore.Mvc.Routing.ControllerActionEndpointDataSource.<>c.<AddDynamicControllerEndpoint>b__16_0(HttpContext context)
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.Invoke(HttpContext httpContext)
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at Nop.Services.Authentication.AuthenticationMiddleware.InvokeAsync(HttpContext context) in M:\Production\nopCommerce_4.50.3to4_Development\src\Libraries\Nop.Services\Authentication\AuthenticationMiddleware.cs:line 94
   at StackExchange.Profiling.MiniProfilerMiddleware.Invoke(HttpContext context) in C:\projects\dotnet\src\MiniProfiler.AspNetCore\MiniProfilerMiddleware.cs:line 103
   at WebMarkupMin.AspNetCore6.WebMarkupMinMiddleware.ProcessAsync(HttpContext context, Boolean useMinification, Boolean useCompression)
   at WebMarkupMin.AspNetCore6.WebMarkupMinMiddleware.ProcessAsync(HttpContext context, Boolean useMinification, Boolean useCompression)
   at WebMarkupMin.AspNetCore6.WebMarkupMinMiddlewareBase.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
   at Nop.Services.Installation.InstallUrlMiddleware.InvokeAsync(HttpContext context, IWebHelper webHelper) in M:\Production\nopCommerce_4.50.3to4_Development\src\Libraries\Nop.Services\Installation\InstallUrlMiddleware.cs:line 52
   at Nop.Services.Common.KeepAliveMiddleware.InvokeAsync(HttpContext context, IWebHelper webHelper) in M:\Production\nopCommerce_4.50.3to4_Development\src\Libraries\Nop.Services\Common\KeepAliveMiddleware.cs:line 49
   at Microsoft.AspNetCore.ResponseCompression.ResponseCompressionMiddleware.InvokeCore(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.HandleException(HttpContext context, ExceptionDispatchInfo edi)
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
1 mese tempo fa
I cannot reproduce this error on my machine.
What VS version you use?
1 mese tempo fa
Version 17.9.2
1 mese tempo fa
I Googled too.  No mentions of it happening to anyone else.  This came up showing the code in aspnetcore lib:
https://github.com/dotnet/aspnetcore/blob/main/src/Mvc/Mvc.Core/src/Routing/ControllerActionEndpointDataSource.cs

This blog has explanation (in Chinese, but Google translates), but it's not very clear (to me):
https://www.cnblogs.com/zhangnever/p/17131504.html
1 mese tempo fa
Yes that was the only page I found - Not sure it is about someone getting the error
or more about describing the code and that error appears in dotnet github source in the link you provided
1 mese tempo fa
Same thing is happening with me as well with NopCommerce 4.50.4 . Homepage loads but the login and admin page run into this issue
1 mese tempo fa
It would be interesting to go back to some previous version of Visual Studio and see if that is the cause of the error.
Or maybe the problem is as a reult of an update to .Dotnet - but I cannot remember doing an update.
Either way it apprears to have become an issue since I last was working on 4.5 code  back in January.
1 mese tempo fa
In Visual Studio, does it happen for running in both "IIS Express" and "Nop.Web"?
1 mese tempo fa
In my case, it is not working with IIS only. I am able to run the project with "Nop.Web" . The IIS express is inconsistent as well. It doesn't work most of the time and it keeps throwing the same exception but it worked once or twice, not sure why. The error only started appearing today as it was fine yesterday


UPDATE: Run into the same issue with Nop.Web too
1 mese tempo fa
I just opened a project that worked 2 years ago, was untouched until today.
I am getting this error.
I have updated Visual Studio 2022 to 17.9.1 and I have installed dotnet 8.