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