Closed munchkindev closed 3 years ago
Hi @munchkindev,
Not sure if I get your problem. So do you have any exact build error or not? Your project is running or not?
Some suggestions:
Startup.cs
basically for me 1 line is important. And you added my services so it is ok. However example is missing every important details in _Layout.cshtml
file. I can see the HTML markup and you using variables. But those variables are declared somewhere? What is below this HTML? Is there a @code {...}
block or a .cs
codebehind file where variables declared? -> Learning new frameworks in a new language with new tools is always hard. So recommend to watch some Blazor videos and go through some tutorials. Learn how Blazor works how it is structured, etc. So you can use codebihing
or @code { ..}
blocks, learn DI and usage via @inject
also @using
is important you can do it globally in _Imports.razor
, etc. When confident in the built in features and the way the framework works then start using 3rd party extensions.<button @onclick="" ..
that is simple Balzor so should work or might be the event handler code is invalid). -> Try to use VS 2019 Stable channel so you won't get incomplete and buggy features and judge VS wrong.Conclusion is currently .NET 6 is not officially supported but probably all should be ok. Check my suggestions and go through the demo again especially to the @code {}
block and _Imports.razor
. Right know cannot tell you if it is an issue with the component with .NET 6 or you have incorrect setup.
Let me know if you found the problem or need more help.
Hi @majorimi,
Thanks for your extensive and very informational answer.
I might've messed up there - it seems I am using .NET Core 6 and not Blazor? Maybe that's the issue? That's how my hello world app looks like:
Not sure if I get your problem. So do you have any exact build error or not? Your project is running or not?
You understood the problem correctly. The project gets a build error and doesn't run.
is important you can do it globally in _Imports.razor, etc.
It appears there is only a _ViewImports.cshtml
file in my project... At least it's the most similar one.
Ah now I got it.... .cshtm
is probably for MVC application. So it is .Net 6 application it is not Blazor! You can use Blazor components in existing MVC applications. But if it's a new app recommend to drop it and create a new Blazor project.
Also closing this since this issue is not related to my component.
Sorry for reopening this again and sorry for asking this since this has 0 relevance to the component, but the choice against Blazor was that it forces you to develop SPA (Single page applications), which is not good for SEO... Or is this false information?
Partially true.... When you create a Blazor WASM application (client side) then yes it is true. But Blazor is super flexible it has many hosting models. You can have server side/server hosted Balzor with different render options. Check out render-mode options there is even a "hybrid" where your app renders some HTML to show in the browser (this HTML can have meta tags) and then app will switch to WASM mode.
So Blazor is not a SPA framework as you might think. It is a component based "Web" application framework. And even "WEB" is in quotes since Blazor will be everywhere pretty soon... If not there already... If you write your Blazor components correctly (e.g. no DB or private resource access in the components which will fail on WASM mode) then you can use the SAME components in all apps below:
Even at any point in time you just "port" your application from Server side to WASM or Electron on Mobile with "minimal" effort... Hope this answered your questions.
Thank you so much for answering this so in-depth and even though it was completely not related to your component, I really really appreciate it!
Hello,
So I followed the tutorial on how to implement a modal/banner,
My
Startup.cs
:No errors appeared here. But as soon as I add the code for the banner/modal into
_Layout.cshtml
or any new shared razor page I get a lot of errors. The most common error type is Name X is not available in current context. Here's a screenshot of the errors marked.I am using .NET Core 6 (Blazor) on Visual Studio 2022 Preview 3.1
P.S. yes I'm a beginner at .NET Core and C# in general