{ expected when creating new razor page.
I created a blazor project, went to add a new page, write something in the @{} block and get red squiggly lines.
46 Replies
Following this article: https://blazor-university.com/overview/creating-a-page/
Blazor University
Blazor University - Creating a page
googling yields various issues but no solution
I am not familiar with razor pages but your code does not seems to match the one you linked
@{...}
vs. @code { ... }
for example
Looks like that should be fine, nvmYes, correct, but I suspect the issue is related because I get the same errors if I have that @code anyway.
What happens when you leave the model out?
Same thing unfortunatenyl.
I suspect there's something wrong with related files, but I'm too new to know what's going on.
If I keep nothing but the @page and the @{} i get no errors, but that doesn't help because I need to be able to write something heh
Do you have a matching
.cs
file?Yes, they get made automatically.
Are there squiggly lines in there?
Nope
Is your project public? And did you pick .NET 6?
.net 6 picked yes
where do i see if its public?
Public = public repository on github or somewhere else
its a fresh creation of project
it's not published to the web no
So that we can check it out
Let me try it myself, sec
create new project, blazor server app -> rightclick 'pages' - > add new razor page
Oh wait
blazor?
I see, let me try 😄 E: Updating VS 💤
^^
The typical bloat ;D
Okay
So you need to specify that model
Otherwise I am getting the errors you get
what happens when you start writing code in the code block?
Works for me now
Can you show your cs file?
Your naming is btw flawed
Should be uppercase
Test.cshtml
And TestModel
, Test.cshtml.cs
Ok
Okay
And I am getting more issues now when specifying
Title
in thereit's as if some controlling related file is pushing errors to the page we're at... I tried adding a nav entry but that didn't help
yes i tried that
same errors though, and it didn't elaborate on it
This is a part of the default project
razor file
With code in it
aye, but adding a new page should be possible
This feels weird to me
Not sure why you should give the file a
razor
extension
It is dedicated to components afaik -> != page
This is also specifying a page
So they want you to create a razor file I assume
No cshtml
and cshtml.cs
Stack Overflow
What is the difference between "razor" and "cshtml" files?
What is the difference between "razor" and "cshtml" files in ASP.NET. Should we use ".razor" file in "razor-components" application instead of ".cshtml&...
Seems like no one knows haha
tl;dr create a
razor
fileok so creating a razor page is bugged then
i just created a razor component and i also hope that it will not limit my usage of it in terms of using it as a page?
It is a page
@page
marks it as a pageok, great
The creation process of a page is not bugged
Just not intuitive
Nvm you are right
It says razor component
Yeah, very bad
but i add a @page directive and i should be good to go?
Definitely
thanks a bunch for helping me out
It is the "new" way
And seems like it is also the only way now
(check the SO link from above)
You are welcome!
Have a good one!
cheers, see yya