C
Join ServerC#
help
{ expected when creating new razor page.
PPopulus10/16/2022
I created a blazor project, went to add a new page, write something in the @{} block and get red squiggly lines.

PPopulus10/16/2022
Following this article: https://blazor-university.com/overview/creating-a-page/
PPopulus10/16/2022
googling yields various issues but no solution
Qqqdev10/16/2022
I am not familiar with razor pages but your code does not seems to match the one you linked
Qqqdev10/16/2022
@{...}
vs. @code { ... }
for exampleQqqdev10/16/2022
Looks like that should be fine, nvm
PPopulus10/16/2022
Yes, correct, but I suspect the issue is related because I get the same errors if I have that @code anyway.
Qqqdev10/16/2022

Qqqdev10/16/2022
What happens when you leave the model out?
PPopulus10/16/2022
Same thing unfortunatenyl.
PPopulus10/16/2022
I suspect there's something wrong with related files, but I'm too new to know what's going on.
PPopulus10/16/2022
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
Qqqdev10/16/2022
Do you have a matching
.cs
file?PPopulus10/16/2022
Yes, they get made automatically.
Qqqdev10/16/2022
Are there squiggly lines in there?
PPopulus10/16/2022
Nope
Qqqdev10/16/2022
Is your project public? And did you pick .NET 6?
PPopulus10/16/2022
.net 6 picked yes
PPopulus10/16/2022
where do i see if its public?
Qqqdev10/16/2022
Public = public repository on github or somewhere else
PPopulus10/16/2022
its a fresh creation of project
PPopulus10/16/2022
it's not published to the web no
Qqqdev10/16/2022
So that we can check it out
Qqqdev10/16/2022
Let me try it myself, sec
PPopulus10/16/2022
create new project, blazor server app -> rightclick 'pages' - > add new razor page
Qqqdev10/16/2022
Oh wait
Qqqdev10/16/2022
blazor?
Qqqdev10/16/2022
I see, let me try 😄 E: Updating VS 💤
PPopulus10/16/2022
^^
Qqqdev10/16/2022
The typical bloat ;D
Qqqdev10/16/2022
Okay
Qqqdev10/16/2022
So you need to specify that model
Qqqdev10/16/2022
Otherwise I am getting the errors you get
PPopulus10/16/2022
what happens when you start writing code in the code block?
PPopulus10/16/2022

Qqqdev10/16/2022
Works for me now
Qqqdev10/16/2022
Can you show your cs file?
Qqqdev10/16/2022
Your naming is btw flawed
Qqqdev10/16/2022
Should be uppercase
PPopulus10/16/2022

Qqqdev10/16/2022
Test.cshtml
Qqqdev10/16/2022
And
TestModel
, Test.cshtml.cs
PPopulus10/16/2022
Ok
Qqqdev10/16/2022
Okay
Qqqdev10/16/2022
And I am getting more issues now when specifying
Title
in therePPopulus10/16/2022
it'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
Qqqdev10/16/2022

PPopulus10/16/2022
yes i tried that
PPopulus10/16/2022
same errors though, and it didn't elaborate on it
Qqqdev10/16/2022

Qqqdev10/16/2022
This is a part of the default project
Qqqdev10/16/2022
razor file
Qqqdev10/16/2022
With code in it
PPopulus10/16/2022
aye, but adding a new page should be possible
Qqqdev10/16/2022
This feels weird to me
Qqqdev10/16/2022
Not sure why you should give the file a
razor
extensionQqqdev10/16/2022
It is dedicated to components afaik -> != page
Qqqdev10/16/2022
This is also specifying a page
Qqqdev10/16/2022
So they want you to create a razor file I assume
Qqqdev10/16/2022
No
cshtml
and cshtml.cs
Qqqdev10/16/2022

Qqqdev10/16/2022
Seems like no one knows haha
Qqqdev10/16/2022
tl;dr create a
razor
filePPopulus10/16/2022
ok so creating a razor page is bugged then
PPopulus10/16/2022
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?
Qqqdev10/16/2022
It is a page
Qqqdev10/16/2022
@page
marks it as a pagePPopulus10/16/2022
ok, great
Qqqdev10/16/2022
The creation process of a page is not bugged
Qqqdev10/16/2022
Just not intuitive
Qqqdev10/16/2022
Nvm you are right
Qqqdev10/16/2022
It says razor component
Qqqdev10/16/2022
Yeah, very bad
PPopulus10/16/2022
but i add a @page directive and i should be good to go?
Qqqdev10/16/2022
Definitely
PPopulus10/16/2022
thanks a bunch for helping me out
Qqqdev10/16/2022
It is the "new" way
Qqqdev10/16/2022
And seems like it is also the only way now
Qqqdev10/16/2022
(check the SO link from above)
Qqqdev10/16/2022
You are welcome!
Qqqdev10/16/2022
Have a good one!
PPopulus10/16/2022
cheers, see yya