We have an MVC.Net 2 application that works with .Net 4.0. There are times when the embedded code in our views may be mistaken when sending the wrong HTML to the browser.
How can I tell Internet Explorer to close any public attributes and elements so that it can correctly display an error message?
In order to catch and write errors in the embedded code, I include the HTML representation code and the embedded code in the try block of the try-catch structure and just want a simple message to be output after the error message.
Example:
<%
try {
%>
<div id="div1">
<label class="<%=embedded.code.that.may.err%>">mylabel</label>
<div id="div2" class="data-style">
<%=more.embedded.code.that.may.err%>
</div>
</div>
<%
}
catch(Exception ex) {
(new LogManager()).Save(ex);
%>
<div style="color:red;font-weight:bold;font-size:large;">
Sorry, there was an error.
</div>
<%
}
%>
source
share