C
C#•2y ago
populus

{ 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
populus
populus•2y ago
googling yields various issues but no solution
qqdev
qqdev•2y ago
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, nvm
populus
populus•2y ago
Yes, correct, but I suspect the issue is related because I get the same errors if I have that @code anyway.
qqdev
qqdev•2y ago
qqdev
qqdev•2y ago
What happens when you leave the model out?
populus
populus•2y ago
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
qqdev
qqdev•2y ago
Do you have a matching .cs file?
populus
populus•2y ago
Yes, they get made automatically.
qqdev
qqdev•2y ago
Are there squiggly lines in there?
populus
populus•2y ago
Nope
qqdev
qqdev•2y ago
Is your project public? And did you pick .NET 6?
populus
populus•2y ago
.net 6 picked yes where do i see if its public?
qqdev
qqdev•2y ago
Public = public repository on github or somewhere else
populus
populus•2y ago
its a fresh creation of project it's not published to the web no
qqdev
qqdev•2y ago
So that we can check it out Let me try it myself, sec
populus
populus•2y ago
create new project, blazor server app -> rightclick 'pages' - > add new razor page
qqdev
qqdev•2y ago
Oh wait blazor? I see, let me try 😄 E: Updating VS 💤
populus
populus•2y ago
^^
qqdev
qqdev•2y ago
The typical bloat ;D Okay So you need to specify that model Otherwise I am getting the errors you get
populus
populus•2y ago
what happens when you start writing code in the code block?
populus
populus•2y ago
qqdev
qqdev•2y ago
Works for me now Can you show your cs file? Your naming is btw flawed Should be uppercase
populus
populus•2y ago
qqdev
qqdev•2y ago
Test.cshtml And TestModel, Test.cshtml.cs
populus
populus•2y ago
Ok
qqdev
qqdev•2y ago
Okay And I am getting more issues now when specifying Title in there
populus
populus•2y ago
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
qqdev
qqdev•2y ago
populus
populus•2y ago
yes i tried that same errors though, and it didn't elaborate on it
qqdev
qqdev•2y ago
qqdev
qqdev•2y ago
This is a part of the default project razor file With code in it
populus
populus•2y ago
aye, but adding a new page should be possible
qqdev
qqdev•2y ago
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
qqdev
qqdev•2y ago
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&...
qqdev
qqdev•2y ago
qqdev
qqdev•2y ago
Seems like no one knows haha tl;dr create a razor file
populus
populus•2y ago
ok 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?
qqdev
qqdev•2y ago
It is a page @page marks it as a page
populus
populus•2y ago
ok, great
qqdev
qqdev•2y ago
The creation process of a page is not bugged Just not intuitive Nvm you are right It says razor component Yeah, very bad
populus
populus•2y ago
but i add a @page directive and i should be good to go?
qqdev
qqdev•2y ago
Definitely
populus
populus•2y ago
thanks a bunch for helping me out
qqdev
qqdev•2y ago
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!
populus
populus•2y ago
cheers, see yya