Suchiman / BlazorDualMode

Demo on how to run dynamically in client or server side mode
MIT License
145 stars 24 forks source link

Cannot find the fallback endpoint specified by route values: { page: /_Host, area: }. #12

Closed ghost closed 4 years ago

ghost commented 4 years ago

I created a project with .Net 3.1 exactly as I saw in the project source but when I set the .server project as startup I get this error: Cannot find the fallback endpoint specified by route values: { page: /_Host, area: }. when I set the .client project as startup I get: No webpage was found for the web address: http://localhost:60773/ I want to use this project since someone said I can make a client side project and debug it like the server side. How do I run the project correctly?

Suchiman commented 4 years ago

Have you moved the index.html from the .Client project as _Host.cshtml into the Pages directory of the .Server project like in the sample code?

ghost commented 4 years ago

Yes I did, There are 2 screenshots of the project that i attached. 2019-11-15 (1)

2019-11-15

ghost commented 4 years ago

Visual studio brought a golden bar that says an invalidoperationexception happened and that it can be caused by an extension, And the log file it showed me has two areas of errors: (I didn't install any extensions after installing vs 2019 preview)

224 ERROR Still unable to load MEF component DLL: Could not load file or assembly 'Microsoft.VisualStudio.CppSvc.Internal, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.          C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\Common7\IDE\CommonExtensions\Microsoft\CodeAnalysis\Microsoft.VisualStudio.CodeAnalysis.VCPlugin.dll     Microsoft.VisualStudio.ComponentModelHost.VsShellComponentModelHost 2019/11/15 17:29:31.232
664 ERROR System.InvalidOperationException: The operation failed as details for project MiladJob.Server could not be loaded. at NuGet.PackageManagement.VisualStudio.NetCorePackageReferenceProject.GetPackageSpecsAsync(DependencyGraphCacheContext context) at NuGet.PackageManagement.DependencyGraphRestoreUtility.d7.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at NuGet.SolutionRestoreManager.SolutionRestoreJob.d19.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) at NuGet.SolutionRestoreManager.SolutionRestoreJob.d17.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at NuGet.SolutionRestoreManager.SolutionRestoreJob.d17.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at NuGet.SolutionRestoreManager.SolutionRestoreJob.d__16.MoveNext()     NuGet Package Manager 2019/11/15 17:31:56.836
733 ERROR System.InvalidOperationException: The operation failed as details for project MiladJob.Server could not be loaded. at NuGet.PackageManagement.VisualStudio.NetCorePackageReferenceProject.GetPackageSpecsAsync(DependencyGraphCacheContext context) at NuGet.PackageManagement.DependencyGraphRestoreUtility.d7.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at NuGet.SolutionRestoreManager.SolutionRestoreJob.d19.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) at NuGet.SolutionRestoreManager.SolutionRestoreJob.d17.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at NuGet.SolutionRestoreManager.SolutionRestoreJob.d17.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at NuGet.SolutionRestoreManager.SolutionRestoreJob.d__16.MoveNext()     NuGet Package Manager 2019/11/15 17:32:37.235
742 ERROR Loading UI library
866 ERROR System.InvalidOperationException: Writing is not allowed after writer was completed. at System.IO.Pipelines.Pipe.GetMemory(Int32 sizeHint) at System.IO.Pipelines.Pipe.DefaultPipeWriter.GetMemory(Int32 sizeHint) at StreamJsonRpc.HeaderDelimitedMessageHandler.Write(JsonRpcMessage content, CancellationToken cancellationToken) at StreamJsonRpc.PipeMessageHandler.WriteCoreAsync(JsonRpcMessage content, CancellationToken cancellationToken) at StreamJsonRpc.MessageHandlerBase.d15.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at StreamJsonRpc.JsonRpc.d118.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Threading.Tasks.ValueTask.ThrowIfCompletedUnsuccessfully() at StreamJsonRpc.JsonRpc.d102.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at StreamJsonRpc.JsonRpc.d961.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.VisualStudio.CodeLens.Proxy.CodeLensHubClient.<>c__DisplayClass22_01.<b0>d.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.VisualStudio.Text.Utilities.GuardedOperations.d36`1.MoveNext() --- End of stack trace from previous location where exception was thrown --- at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)
ghost commented 4 years ago

I commented out these two Item groups in Project xml file and project runs:

`<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <LangVersion>7.3</LangVersion>
  </PropertyGroup>

  <!--<ItemGroup>
    <Content Remove="Pages\_host.cshtml" />
  </ItemGroup>

  <ItemGroup>
    <None Include="Pages\_Host.cshtml" />
  </ItemGroup>-->

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Blazor.Server" Version="3.1.0-preview2.19528.8" />
  </ItemGroup>
`

Now How do I run and debug Client project?

Suchiman commented 4 years ago

You run the .Server (always), and if you need debugging, you run in server mode by appending ?mode=server, then you can set breakpoints in your .Client project and hit them

ghost commented 4 years ago

One more question please: How do I deploy client project to a static file server without an index.html in wwwroot folder? I only need the client project, Thank you in advance.

Suchiman commented 4 years ago

In that case you need to keep your index.cshtml around and in sync with _Host.cshtml