Skip to content
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

InvalidCastException: Unable to cast object of type 'Microsoft.AspNetCore.Components.WebView.Services.WebViewNavigationManager' to type 'Microsoft.AspNetCore.Components.Routing.IHostEnvironmentNavigationManager'. #47613

Closed
1 task done
mediabuff opened this issue Apr 8, 2023 · 3 comments
Labels
area-blazor Includes: Blazor, Razor Components ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. question Status: Resolved

Comments

@mediabuff
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Hi,
I am trying to host Razor views (*.cshtml) in an hybrid wpf app (BlazorWebView). Got everyting working with memory based OWIN loopback. But ran into this cast when Microsoft.AspNetCore.Mvc.ViewFeatures.StaticComponentRenderer tries to render it.

It appears webview NavigationManager does not implement IHostEnvironmentNavigationManager, which the MVC stack expects.

Should'nt webview NavigationManager be implemented similiar to

https://github.com/dotnet/aspnetcore/blob/main/src/Components/Server/src/Circuits/RemoteNavigationManager.cs

Expected Behavior

Implement IHostEnvironmentNavigationManager on Webview NavigationManager.

Steps To Reproduce

Start with Wpf Hybrid app and add MVC stack with owin middleware.

Exceptions (if any)

InvalidCastException

.NET Version

.Net 7

Anything else?

No response

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-blazor Includes: Blazor, Razor Components label Apr 8, 2023
@javiercn
Copy link
Member

@mediabuff thanks for contacting us.

This is not a scenario we support, nor something we plan to address. It seems that you are trying to host newer features (components) inside an older version of the framework. This is not something we plan to address, it does not make sense for Components Webview to take a dependency on ASP.NET Core.

@javiercn javiercn added question ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. labels Apr 10, 2023
@ghost ghost added the Status: Resolved label Apr 10, 2023
@mediabuff
Copy link
Author

Thanks for your quick response.
a) >>to host newer features (components) inside an older version of the framework.
Well, then what is the right way to host Razor views (*.cshtml) in wpf ?

b)
I have shared code in Blazor Server and Wpf Blazor Hybrid. For Server, the start page is _Host.cshml, but for wpf it is index. html. I have quite of a bit of dynamic content in _host.cshml - how do I get that in wpf index.html without hosting Razor views in wpf.

@ghost
Copy link

ghost commented Apr 11, 2023

This issue has been resolved and has not had any activity for 1 day. It will be closed for housekeeping purposes.

See our Issue Management Policies for more information.

@ghost ghost closed this as completed Apr 11, 2023
@ghost ghost locked as resolved and limited conversation to collaborators May 11, 2023
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. question Status: Resolved
Projects
None yet
Development

No branches or pull requests

2 participants