How can I check all the code enclosed between the brackets of the <% and%> aspx files during assembly?

I am starting to use Asp.net MVC. It is recommended to use tags <%and %>to insert the source code in HTML, because it is easier to read.

Unfortunately, although Visual Studio cannot detect errors during compilation. This is very bad.

For example:

<body>
    <form action="LogOn.aspx">
        <div>
            <div><label for="txtLogOn_UserName"><%= LogOnView.UserName %> :</label></div>
            <div><%= Html.TextBox("txtLogOn_UserName")%></div>            
        </div>
    </form>
</body>

How can I be sure that LogOnView.UserNameis a valid statement? By analogy, the code is similar to JS code; you cannot know if there will be errors until you run them.

A possible solution may be to create a test project, but I do not like this idea, and I do not think that I will need to create a test project to solve this problem.

. , .

+3
1

aspnet_compiler :

C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler -v / -p "$(ProjectDir)\"

.

.NET 4.0:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler -v / -p "$(ProjectDir)\"
+4

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


All Articles