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

**URL:** https://talk.remobjects.com/t/asp-net-core-mvc-razor-still-requires-some-c-syntax/24818
**Category:** Water
**Tags:** net, mercury
**Created:** [May 22, 2021, 3:06pm UTC](https://talk.remobjects.com/t/asp-net-core-mvc-razor-still-requires-some-c-syntax/24818 "2021-05-22T15:06:27Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![avonelle](https://talk.remobjects.com/user_avatar/talk.remobjects.com/avonelle/32/13001_2.png) [@avonelle](https://talk.remobjects.com/u/avonelle)
#### Post date: [May 22, 2021, 3:06pm UTC](https://talk.remobjects.com/t/asp-net-core-mvc-razor-still-requires-some-c-syntax/24818/1 "2021-05-22T15:06:27Z")

</div>

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

 ![image](https://talk.remobjects.com/uploads/default/original/2X/0/0edd3ef8838594c9477e81892f67c6dfd7be82ea.png)

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

 ![image](https://talk.remobjects.com/uploads/default/original/2X/a/a7aa8b2a1193d06cb74a827e78105b2183143b9b.png)

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.  
 ![image](https://talk.remobjects.com/uploads/default/original/2X/9/9c22de45d3bcc06d86de16d380886e30701628eb.png)

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

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [May 24, 2021, 12:26pm UTC](https://talk.remobjects.com/t/asp-net-core-mvc-razor-still-requires-some-c-syntax/24818/2 "2021-05-24T12:26:08Z")

</div>

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](http://ASP.NET)’s classic `<%...%>`, how C# interim’s with HTML in a .cshtml is _very_ language specific ☹

---

<div class="post-metadata">

### Author: ![avonelle](https://talk.remobjects.com/user_avatar/talk.remobjects.com/avonelle/32/13001_2.png) [@avonelle](https://talk.remobjects.com/u/avonelle)
#### Post date: [May 24, 2021, 12:30pm UTC](https://talk.remobjects.com/t/asp-net-core-mvc-razor-still-requires-some-c-syntax/24818/3 "2021-05-24T12:30:33Z")

</div>

Understood. Bummer.

–Avonelle

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [May 24, 2021, 1:06pm UTC](https://talk.remobjects.com/t/asp-net-core-mvc-razor-still-requires-some-c-syntax/24818/4 "2021-05-24T13:06:42Z")

</div>

> [@avonelle](#):
>
> Understood. Bummer.

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

---

<div class="post-metadata">

### Author: ![avonelle](https://talk.remobjects.com/user_avatar/talk.remobjects.com/avonelle/32/13001_2.png) [@avonelle](https://talk.remobjects.com/u/avonelle)
#### Post date: [May 24, 2021, 1:23pm UTC](https://talk.remobjects.com/t/asp-net-core-mvc-razor-still-requires-some-c-syntax/24818/5 "2021-05-24T13:23:01Z")

</div>

90% of the active projects I support are [ASP.NET](http://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

---

<div class="post-metadata">

### Author: ![Theo69](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/t/35a633/32.png) [@Theo69](https://talk.remobjects.com/u/Theo69)
#### Post date: [May 26, 2021, 12:26pm UTC](https://talk.remobjects.com/t/asp-net-core-mvc-razor-still-requires-some-c-syntax/24818/6 "2021-05-26T12:26:05Z")

</div>

> [@avonelle](#):
>
> 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.

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

---

<div class="post-metadata">

### Author: ![avonelle](https://talk.remobjects.com/user_avatar/talk.remobjects.com/avonelle/32/13001_2.png) [@avonelle](https://talk.remobjects.com/u/avonelle)
#### Post date: [May 26, 2021, 12:48pm UTC](https://talk.remobjects.com/t/asp-net-core-mvc-razor-still-requires-some-c-syntax/24818/7 "2021-05-26T12:48:24Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Theo69](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/t/35a633/32.png) [@Theo69](https://talk.remobjects.com/u/Theo69)
#### Post date: [May 26, 2021, 12:59pm UTC](https://talk.remobjects.com/t/asp-net-core-mvc-razor-still-requires-some-c-syntax/24818/8 "2021-05-26T12:59:39Z")

</div>

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).

---

<div class="post-metadata">

### Author: ![Patrick](https://talk.remobjects.com/user_avatar/talk.remobjects.com/patrick/32/14_2.png) [@Patrick](https://talk.remobjects.com/u/Patrick)
#### Post date: [May 26, 2021, 1:01pm UTC](https://talk.remobjects.com/t/asp-net-core-mvc-razor-still-requires-some-c-syntax/24818/9 "2021-05-26T13:01:38Z")

</div>

> [@Theo69](#):
>
> You know that IE will be removed by Microsoft soon, for Windows 10?

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](https://pureinfotech.com/enable-ie-mode-microsoft-edge-chromium/)

---

<div class="post-metadata">

### Author: ![Theo69](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/t/35a633/32.png) [@Theo69](https://talk.remobjects.com/u/Theo69)
#### Post date: [May 26, 2021, 1:04pm UTC](https://talk.remobjects.com/t/asp-net-core-mvc-razor-still-requires-some-c-syntax/24818/10 "2021-05-26T13:04:28Z")

</div>

> [@Patrick](#):
>
> 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.

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

---

<div class="post-metadata">

### Author: ![Theo69](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/t/35a633/32.png) [@Theo69](https://talk.remobjects.com/u/Theo69)
#### Post date: [May 26, 2021, 1:27pm UTC](https://talk.remobjects.com/t/asp-net-core-mvc-razor-still-requires-some-c-syntax/24818/11 "2021-05-26T13:27:04Z")

</div>

> [@avonelle](#):
>
> 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

For the creation of custom components, see [Free Style UI Components with Web Components and Web Assembly | by Swati Sucharita | Medium](https://medium.com/@swatisucharita94/free-style-ui-components-with-web-components-and-web-assembly-c7febe721b75)

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

> **[9 Web Components UI Libraries You Should Know in 2021](https://blog.bitsrc.io/9-web-component-ui-libraries-you-should-know-in-2019-9d4476c3f103)**
>
> Looking for framework-agnostic web components? Take a look

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

---

<div class="post-metadata">

### Author: ![avonelle](https://talk.remobjects.com/user_avatar/talk.remobjects.com/avonelle/32/13001_2.png) [@avonelle](https://talk.remobjects.com/u/avonelle)
#### Post date: [May 26, 2021, 3:35pm UTC](https://talk.remobjects.com/t/asp-net-core-mvc-razor-still-requires-some-c-syntax/24818/12 "2021-05-26T15:35:18Z")

</div>

> [@Patrick](#):
>
> 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.

Very good to know, thanks!

> [@Theo69](#):
>
> As thirth party components, all Web Components are usable,

Good point. I keep forgetting this. Duh!

–Avonelle
