Is there a tidier way to have a comma after @variable in a razor

I have a razor mapping pattern in MVC3 for an address. The following is a coding example that I used for a single address line:

@Model.City<text>,</text>

When I put a comma right after the variable name, it creates a syntax error. Adding a <text> tag around the comma fixes the problem, but it seems a bit messy when most of the razor code is so neat and concise.

Is there a tidier and more concise way to do this?

Edit: This piece of code is inside an if block. I did not understand, but it turns out that this affects how razar parses the material.

+3
source share
1 answer

, , :

@(Model.City).

:

@Model.City@('.')

a >


: .
(@if, @for, @{ ... }) Razor , ( ).

HTML <text>, , .
, ,, #.

, <text>, , , @:

@Model.City@:,
+10

Source: https://habr.com/ru/post/1793591/


All Articles