0

我正在尝试在 ASP.NET 中部署一个使用 VS2010 开发的简单 Web 应用程序,在开发机器上本地的 IIS 上一切正常,但是一旦部署在 Apache 服务器上,我遇到了一个问题:菜单无法正确呈现,似乎不考虑 CSS。

有没有人已经有这样的问题?谢谢你的帮助 !

[编辑] Appache 版本 2.2.22 Mono 版本 2.10.8.1

Site.Master:

<body>
<form runat="server">
    <div class="page">
        <div class="TopBlank"> </div>
        <div class="header">
            <div class="title">
                <h1>
                    My ASP.NET Application
                </h1>
            </div>            
            <div class="clear hideSkiplink">
                <asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="false" IncludeStyleBlock="false" Orientation="Horizontal">
                <Items>
                    <asp:MenuItem NavigateUrl="~/Default.aspx" Text="Home"/>
                    <asp:MenuItem Text="Google Maps">
                        <asp:MenuItem Text="HTML" Value="HTML" NavigateUrl="~/Map.htm"></asp:MenuItem>
                        <asp:MenuItem Text="ASPX" Value="ASPX" NavigateUrl="~/Map.aspx"></asp:MenuItem>
                    </asp:MenuItem>
                    <asp:MenuItem NavigateUrl="~/Liens.aspx" Text="Liens utiles"/>
                    <asp:MenuItem NavigateUrl="~/About.aspx" Text="About"/>
                </Items>
            </asp:Menu>
        </div>
    </div>
</form>
</body>

CSS:

.menu
{
    padding: 4px 0px 4px 8px;
}

.menu ul
{
    list-style: none;
    margin: 0px;
    padding: 0px;
    width: auto;
}

.menu ul li a, .menu ul li a:visited
{
    background-color: #465c71;
    border: 1px #4e667d solid;
    color: #dde4ec;
    display: block;
    line-height: 1.35em;
    padding: 4px 20px;
    text-decoration: none;
    white-space: nowrap;
}

.menu ul li a:hover
{
    background-color: #bfcbd6;
    color: #465c71;
    text-decoration: none;
}

.menu ul li a:active
{
    background-color: #465c71;
    color: #cfdbe6;
    text-decoration: none;
}

.menu ul ul
{
    margin-left: 10%;
}

我发现的问题是,在 IIS 上运行时,asp:menu 被转换为 HTML div,而 mono 被转换为 HTML 表。似乎在单声道上运行时,找不到 CSS 类,如源代码所示:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head><title>

</title><link rel="stylesheet" type="text/css" href="Styles/Site.css" />
<style type="text/css">

.ctl00_NavigationMenu_0 {background-color:White;}
.ctl00_NavigationMenu_1 {border-style:None;text-decoration:none;}
.ctl00_NavigationMenu_2 {}
</style></head>
<body>
    <form name="aspnetForm" method="post" action="Arduino.aspx" id="aspnetForm">
[......]
<div class="clear hideSkiplink">
                <a href="#ctl00_NavigationMenu_SkipLink">
 <img alt="Skip Navigation Links" height="0" width="0" src="/WebSite/WebResource.axd?d=2OmH9jTSogXsrUt6aDvnYEihIak%3d_NWdhSxeypCYSJgIFnBFWuKjP9Rs%3d_f&amp;t=634787585370000000" style="border-width:0px;" /></a>
<table cellpadding="0" cellspacing="0" border="0" id="ctl00_NavigationMenu" class="menu ctl00_NavigationMenu_2" IncludeStyleBlock="false">
    <tr>
        <td onmouseover="javascript:Menu_OverStaticLeafItem ('ctl00_NavigationMenu','0')" onmouseout="javascript:Menu_OutItem ('ctl00_NavigationMenu','0')">
<table id="ctl00_NavigationMenu_0i" cellpadding="0" cellspacing="0" border="0" width="100%">
            <tr>
                <td style="white-space:nowrap;"><a href="Default.aspx" class="ctl00_NavigationMenu_1" id="ctl00_NavigationMenu_0l">Home</a>
</td>
            </tr>
    </table>
</td>
<td style="width:3px;"></td>
<td onmouseover="javascript:Menu_OverItem ('ctl00_NavigationMenu','1',null)" onmouseout="javascript:Menu_OutItem ('ctl00_NavigationMenu','1')">
<table id="ctl00_NavigationMenu_1i" cellpadding="0" cellspacing="0" border="0" width="100%">
        <tr>
            <td style="white-space:nowrap;"><a href="javascript:__doPostBack('ctl00$NavigationMenu','1')" class="ctl00_NavigationMenu_1" id="ctl00_NavigationMenu_1l">Google Maps</a>
</td><td>
<img src="/WebSite/WebResource.axd?d=2OmH9jTSogXsrUt6aDvnYEihIak%3d_sxBDVaG6ao8vAH1kuYRka4pbdXI%3d_f&amp;t=634787585370000000" border="0" alt="Expand Google Maps" />
</td>
        </tr>
    </table> 
    </td>
<td style="width:3px;"></td>
<td onmouseover="javascript:Menu_OverStaticLeafItem ('ctl00_NavigationMenu','2')" onmouseout="javascript:Menu_OutItem ('ctl00_NavigationMenu','2')">
<table id="ctl00_NavigationMenu_2i" cellpadding="0" cellspacing="0" border="0" width="100%">
        <tr>
            <td style="white-space:nowrap;">
<a href="Liens.aspx" class="ctl00_NavigationMenu_1" id="ctl00_NavigationMenu_2l">Liens utiles</a>
</td>
        </tr>
    </table>
    </td>
<td style="width:3px;">
</td>
<td onmouseover="javascript:Menu_OverStaticLeafItem ('ctl00_NavigationMenu','3')" onmouseout="javascript:Menu_OutItem ('ctl00_NavigationMenu','3')">
<table id="ctl00_NavigationMenu_3i" cellpadding="0" cellspacing="0" border="0" width="100%">
        <tr>
            <td style="white-space:nowrap;">
<a href="About.aspx" class="ctl00_NavigationMenu_1" id="ctl00_NavigationMenu_3l">About</a>
</td>
        </tr>
    </table>
</td>
</tr>
</table>
<div class="" id="ctl00_NavigationMenu_1s" style="visibility:hidden;position:absolute;z-index:1;left:0px;top:0px;">
<div id="ctl00_NavigationMenu_1cu" onmouseover="Menu_OverScrollBtn ('ctl00_NavigationMenu','1','u')" onmouseout="Menu_OutScrollBtn ('ctl00_NavigationMenu','1','u')" style="display:block;text-align:center;">
    <img src="/WebSite/WebResource.axd?d=2OmH9jTSogXsrUt6aDvnYEihIak%3d_BDOep8uzgXhnBosTOAXwCS8Rjzo%3d_f&t=634787585370000000" alt="Scroll up" />
</div>
<div id="ctl00_NavigationMenu_1cb">
    <div id="ctl00_NavigationMenu_1cc">
        <table cellpadding="0" cellspacing="0" border="0">
<tr>
    <td onmouseover="javascript:Menu_OverDynamicLeafItem ('ctl00_NavigationMenu','1_0','1')" onmouseout="javascript:Menu_OutItem ('ctl00_NavigationMenu','1_0','1')">
<table id="ctl00_NavigationMenu_1_0i" cellpadding="0" cellspacing="0" border="0" width="100%">
        <tr>
            <td style="width:100%;white-space:nowrap;">
<a href="Map.htm" class="ctl00_NavigationMenu_1" id="ctl00_NavigationMenu_1_0l">HTML</a>
</td>
        </tr>
    </table>
</td>
</tr>
<tr>
    <td onmouseover="javascript:Menu_OverDynamicLeafItem ('ctl00_NavigationMenu','1_1','1')" onmouseout="javascript:Menu_OutItem ('ctl00_NavigationMenu','1_1','1')">
<table id="ctl00_NavigationMenu_1_1i" cellpadding="0" cellspacing="0" border="0" width="100%">
        <tr>
            <td style="width:100%;white-space:nowrap;">
<a href="Map.aspx" class="ctl00_NavigationMenu_1" id="ctl00_NavigationMenu_1_1l">ASPX</a></td>
        </tr>
    </table>
</td>
</tr>
</table>
    </div>
</div>
<div id="ctl00_NavigationMenu_1cd" onmouseover="Menu_OverScrollBtn ('ctl00_NavigationMenu','1','d')" onmouseout="Menu_OutScrollBtn ('ctl00_NavigationMenu','1','d')" style="display:block;text-align:center;">
    <img src="/WebSite/WebResource.axd?d=2OmH9jTSogXsrUt6aDvnYEihIak%3d_BiLWkNe4ZNGZnI7LWDxYAtinS8U%3d_f&t=634787585370000000" alt="Scroll down" />
    </div>
</div>
<a id="ctl00_NavigationMenu_SkipLink"></a>
            </div>

与 IIS 版本进行比较:

<div class="clear hideSkiplink">
            <a href="#NavigationMenu_SkipLink"><img alt="Liens Ignorer la navigation" src="/WebResource.axd?d=vNc13qxX3XhBCykqqeAM4K6DxyzXtiKPMSkmgOEeg_C2LMTfPWT8UVPq_FQ2dO_k8csGANppvDNQ8U1ILvqfCCUzXeU7VT9PTkQGnNHogQU1&amp;t=634679288663570000" width="0" height="0" style="border-width:0px;" /></a><div class="menu" id="NavigationMenu">
<ul class="level1">
   <li>
      <a class="level1" href="Default.aspx">Home</a>
   </li>
   <li>
      <a class="popout level1" href="#" onclick="__doPostBack(&#39;ctl00$NavigationMenu&#39;,&#39;Google Maps&#39;)">Google Maps</a>
         <ul class="level2">
            <li>
               <a class="level2" href="Map.htm">HTML</a>
            </li>
            <li>
               <a class="level2" href="Map.aspx">ASPX</a>
            </li>
         </ul>
   </li>
   <li>
      <a class="level1" href="Liens.aspx">Liens utiles</a>
   </li>
   <li>
   <a class="level1" href="About.aspx">About</a>
   </li>
</ul>
</div>
   <a id="NavigationMenu_SkipLink"></a>
</div>
4

2 回答 2

0

好的,经过几个小时尝试在web.config中找到解决方案,我终于发现解决方案来自mono-apache-server的版本。我使用了 mono-apache-server2 而不是 4。然后我安装了正确的版本,配置了虚拟主机,现在一切正常!

于 2012-12-30T03:40:52.833 回答
0

ASP.NET 放入的锚标记会自动在菜单上方添加额外的垂直空间。一个锚标记会自动放在菜单上方,这会破坏 Internet Explorer 和 Google Chrome 中的呈现。即使使用带有图像的锚点,它也可以在 Mozilla Firefox 中正常工作。

要解决此问题,请将 SkipLinkText="" 属性添加到您的 ASP.NET 菜单控件,这将解决呈现问题。

<asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="false" IncludeStyleBlock="false" Orientation="Horizontal" SkipLinkText="">
于 2013-05-30T16:04:02.923 回答