Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force Visual Studio to fail compile for syntax errors in aspx/ascx pages for ASP.Net?

This is something I should really know how to do but I've never figured it out

How can I force Visual Studio to fail a compile based on what would ultimately be compile/syntax errors in ascx/aspx pages?

For example I could put the following into an ASPX page and the site would compile just fine, but obviously fall over if I visited this page;

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <% if (true) { %>
    <% if (true) { %>
</asp:Content>
like image 272
plenderj Avatar asked Mar 20 '23 14:03

plenderj


1 Answers

Ah just found this in the "related" questions to the right; How can I compile Asp.Net Aspx Pages before loading them with a webserver?

which links to; http://mikehadlow.blogspot.ie/2008/05/compiling-aspx-templates-using.html

So I've added the following as a post-build event to my project;

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_compiler -v / -p "$(SolutionDir)$(ProjectName)"

and it works like a treat!

like image 73
plenderj Avatar answered Apr 06 '23 09:04

plenderj