我们的MVC.Net应用程序有时会返回没有内容的标签。更具体地说,<
和>
之间没有任何内容。使用IE-8开发人员工具检查返回的HTML会显示一个无名标签:<>
及其结束标记:</>
。问题是间歇性的。通常,刷新页面将清除问题。但它足够频繁,用户抱怨管理层希望修复它。
问题发生时,浏览器的HTML源代码如下:
<TR sizcache="5" sizset="47">
<TD class="label table-col-3">
Manager:
</TD>
<TD class="table-col-7 last" sizcache="5" sizset="49">
<A href="http://localhost:57791/Profile/22/Last%2c-First-MI" jQuery1359570774586="26">Last, First MI</A>
</TD>
</TR>
<>
<div>
</div>
</>
通常,浏览器的HTML应如下所示:
<TR sizcache="5" sizset="47">
<TD class="label table-col-3">
Manager:
</TD>
<TD class="table-col-7 last" sizcache="5" sizset="49">
<A href="http://localhost:57791/Profile/22/Last%2c-First-MI" jQuery1359570774586="26">Last, First MI</A>
</TD>
</TR>
<TR id="link-admin-assistant-28" data-update="type: 'replace-portion', dataType: 'html', target: 'link-admin-assistant-28', source: 'link-admin-assistant-28'" sizcache="5" sizset="51">
<TD class="label table-col-3">
Admin Assistant:
</TD>
<TD class="table-col-7 last" sizcache="5" sizset="53">
<A title="Edit Administrative Assistant" href="http://localhost:57791/Person/AdminAssistantForm?clientID=28" jQuery1359570774586="27">Last2, First2 M2</A>
</TD>
</TR>
<TR sizcache="5" sizset="55">
<TD class="label table-col-3">
Type:
</TD>
<TD class="table-col-7 last">
Employee
</TD>
</TR>
应用详情
该应用程序是使用MVC.Net 2构建的。我们已经升级到使用.Net 4.0。还有很多用于客户端脚本和处理AJAX调用的JQuery。
由于视图'* .ascx页面只包含格式良好的HTML5,其中散布着服务器端代码片段,我看不到网络服务器如何返回“&lt;&gt;”标签
问题发生在管理器和矩阵管理器IF块之后的某处。出现问题时,不会显示EmployeeType。
我认为问题发生的代码部分 (基于IE开发工具中的可见HTML)
<% if (managerPersonID != null && managerPersonID > 0 && !managerDisplayName.IsNullOrEmptyTrimmed()) { %>
<tr>
<td class="label table-col-3">Manager:</td>
<td class="table-col-7 last"><%--<a href="<%=Url.Action("Details", new { ID = manager.PersonID, Name = manager.DisplayName, GAL = "" })%>"><%=manager.DisplayName%></a>--%>
<%= Html.ActionLink(managerDisplayName, "Details", "Person", new { ID = managerPersonID, Name = managerDisplayName.Replace(" ", "-"), GAL = "" }, new {}) %>
<%--Matrix Manager--%>
<% if (matrixPersonID != null && matrixPersonID > 0 && !matrixDisplayName.IsNullOrEmptyTrimmed()) { %>
<span class="label">— Matrix:</span>
<%--<a href="<%=Url.Action("Details", new { ID = matrixManager.PersonID, Name = matrixManager.DisplayName, GAL = "" }) %>"><%=matrixManager.DisplayName%></a>--%>
<%= Html.ActionLink(matrixDisplayName, "Details", "Person", new { ID = matrixPersonID, Name = matrixDisplayName.Replace(" ", "-"), GAL = "" }, new {}) %>
<% } %>
</td>
</tr>
<% } %>
<!-- Error seems to occur somewhere after here -->
<%--Sponsoring Manager--%>
<% if (Model.SponsoringManagerPersonID != null && Model.SponsoringManagerPersonID > 0 && !Model.SponsoringManagerDisplayName.IsNullOrEmptyTrimmed()) { %>
<tr>
<td class="label table-col-3">Sponsor:</td>
<td class="table-col-7 last">
<%--<a href="<%=Url.Action("Details", new { ID = Model.SponsoringManager.PersonID, Name = Model.SponsoringManager.DisplayName, GAL = "" })%>"><%=Model.SponsoringManager.DisplayName%></a>--%>
<%= Html.ActionLink(Model.SponsoringManagerDisplayName, "Details", "Person", new { ID = Model.SponsoringManagerPersonID, Name = Model.SponsoringManagerDisplayName.Replace(" ", "-"), GAL = "" }, new {}) %>
</td>
</tr>
<% } %>
<%-- Administrative Assistant --%>
<% Html.RenderPartial("AdminAssistant", Model.AdministrativeAssistant); %>
<%--Employee Type--%>
<tr>
<td class="label table-col-3">Type:</td>
<td class="table-col-7 last">
<%= Enum.GetName(typeof(Person.PersonType), Model.EmployeeType ?? (int)Person.PersonType.Default) %>
</td>
</tr>
<!-- Error appears to occur somewhere before here -->
AdminAssistant部分视图
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<AdminAssistantLink>" %>
<%
bool IsProfileView = ((bool?)ViewData["IsProfileView"]) ?? false;
string AdminAssistLinkID = "link-admin-assistant-" + Model.ProfilePersonID;
%>
<%-- Administrative Assistant --%>
<% if (IsProfileView && Role.AllowProfileEditSpecific(Model.ProfilePersonID)) { %>
<%--Edit mode--%>
<tr id="<%= AdminAssistLinkID %>" data-update="type: 'replace-portion', dataType: 'html', target: '<%= AdminAssistLinkID %>', source: '<%= AdminAssistLinkID %>'">
<td class="label table-col-3">Admin Assistant:</td>
<td class="table-col-7 last">
<% if (Model.AdminAssistantPersonID != null && !Model.AdminAssistantDisplayName.IsNullOrEmptyTrimmed()) { %>
<%-- Display currently selected assistant, with link to edit --%>
<%= Html.ActionLink(Model.AdminAssistantDisplayName, "AdminAssistantForm", "Person", new { clientID = Model.ProfilePersonID }, new { title = "Edit Administrative Assistant" }) %>
<% } else { %>
<%-- Display link to add assistant --%>
<%= Html.ActionLink("Add Administrative Assistant", "AdminAssistantForm", "Person", new { clientID = Model.ProfilePersonID }, new {title = "Add Administrative Assistant" }) %>
<% } %>
</td>
</tr>
<% } else { %>
<%--Link to Profile--%>
<% if (Model.AdminAssistantPersonID != null && !Model.AdminAssistantDisplayName.IsNullOrEmptyTrimmed()) { %>
<tr>
<td class="label table-col-3">Admin Assistant:</td>
<td class="table-col-7 last">
<%= Html.ActionLink(Model.AdminAssistantDisplayName, "Details", "Person", new { ID = Model.AdminAssistantPersonID, Name = Model.AdminAssistantDisplayName.Replace(" ", "-"), GAL = "" }, new {}) %>
</td>
</tr>
<% } %>
<% } %>
答案 0 :(得分:0)
也许这是你的评论标签?这些合法的剃刀语法?
<%--Sponsoring Manager--%>
...
<%-- Administrative Assistant --%>
...
<%--Employee Type--%>
我没有要测试的MVC 2站点,因此我不知道它们将如何显示。 在MVC 3中,标签按原样显示在浏览器标记中。