ASP.NET Core MVC Razor - Still Requires some C# syntax?

Taking a look today at using Mercury with ASP.NET Core. I created a new Mercury project using the “ASP.NET Core MVC/Razor-based Web Application” template.

image

I noticed that it creates an index.cshtml that looks like this:

But this syntax is C#, not VB/Mercury. (Which I guess makes sense, since it is a *.cshtml file.) This compiles successfully, but if I remove the semi-colon, it does not.

I’m surprised, as I was expecting to be able to use Mercury syntax, but that doesn’t appear to be true. Am I missing something? Is it a bug? Or is this “by design”?

Thanks,

–Avonelle

Razor has to go thru Microsoft’s .cshtnml parser to generate C# code that we compile,. That parser can handle only C#, not VB or any of the other languages. (it should handle our C# language extensions, since its not that smart a parser.

To support CB (or Oxygene), we’d not only have to create our own parser for tia, we’d also have to invite ur own syntax, because unlike ASP.NET’s classic <%...%>, how C# interim’s with HTML in a .cshtml is very language specific :frowning:

Understood. Bummer.

–Avonelle

Yeah. That said, I’m not a huge fan of the new ASP.NET Core model at all. Classic ASP.NET was nice. this is just… messy.

90% of the active projects I support are ASP.NET WebForms, so I’m used to “messy”.

I want to figure out what approach I’ll use the next time I need to build something new for the web. Most of the applications I’m building on the web are CRUD forms that do most things server-side. They don’t require high performance and they aren’t high volume applications. What my customers value is rapid development. That’s why the Razor looks somewhat attractive to me, but I’ll be slower for a while no matter what I choose so maybe it doesn’t matter.

The WASM solution is also of interest to me, but I still have users on Internet Explorer, so if I go down that route I’ll need to get buy in from my customers.

–Avonelle

You know that IE will be removed by Microsoft soon, for Windows 10?

Yes, which is both good and bad news, from my standpoint. Good because theoretically I won’t need to support it anymore, and bad because initially I expect to get calls from people saying that suddenly my applications don’t work for them. And I’ve found it won’t necessarily be obvious what is going on. Non-technical users often don’t understand what browser they are using, and I know of at least some who have short cuts to one my web applications on their desktops. I wonder what will happen when IE is gone - I expect those short cuts will just not work since I think they are set to use IE.

So yeah, WASM may be a good alternative moving forward. Although honestly, it seems like overkill for what I need. Basically these are database CRUD applications, and the data is on the server. Yes, I will do some data validation on the client, but it certainly doesn’t require heavy resources, which seems to be the kind of thing that people say WASM is good for. Also, I occasionally end up needing to use third-party components, and I fear that WASM is going to cut me off from that option.

–Avonelle

I use WASM now as a kind of multi-platform Windows Forms and Web Forms alternative.
To be honest; the only thing really missing at this moment is a good (de)serializer for Json and Soap data, and I am working on that right now (first working prototype for Json is ready) - although you can use the Json and Xml document classes for this at this moment.

For server API I still use asmx at this moment (with a small trick changed to a Json instead of soap server).

Don’t forget that Edge has now an IE mode, that can show sites as if they are in IE. Even Silverlight applications run under Edge in this mode.
For more information: How to enable IE Mode on Microsoft Edge Chromium • Pureinfotech

1 Like

I didn’t know that - thanks for the info!

For the creation of custom components, see Free Style UI Components with Web Components and Web Assembly | by Swati Sucharita | Medium

As thirth party components, all Web Components are usable, see by example:

Edit: also, any JS framework is usable with WASM, including their UI extensions.

Very good to know, thanks!

Good point. I keep forgetting this. Duh!

–Avonelle

1 Like