上午还好好可以访问的ASP.NET站点,下午做过一次更新,再访问时,就总是弹出要输入服务器用户名密码对话框(如下图)
如果输入正确,确认三次后,页面报下面的错误:
如果不输用户名密码,直接Cancel,则报下面的错误:
记得以前也发生过两次,有一次是重起机器就好了,所以首先想到的就是重起服务器,但是这次重起后竟然还是不行。于是花近两个小时上网查资料,自己也不停尝试改IIS的配置,怀疑有缓存或Log满了之类的原因,但是都不起作用,而且IIS下只有这个站点不能访问,其它站点都没问题,所以肯定不是Server或IIS本身的问题了,尝试了好半天后才想到可能和本次更新有关(真是后知后觉啊),然后隐隐约约记得好像有一次是Skin文件中有问题导致过类型的错误,赶紧打开Skin文件,把最近加的一段Skin代码拿掉,果然就好了。Oh, My God. 然后再仔细一下,和以前唯一不同的地方是在Skin中用<!---->标记加了一句注释。拿掉注释就没问题了。
<!--Add By Sammy-->(不能用这样的注释)
<asp:ImageButton SkinID="ImageButtonEditPurple" runat="server" ImageUrl="Images/edit_purple.gif" CssClass="image_button"/>
<asp:ImageButton SkinID="ImageButtonCheckPurple" runat="server" ImageUrl="Images/check_purple.gif" CssClass="image_button"/>
<asp:ImageButton SkinID="ImageButtonEditPurple" runat="server" ImageUrl="Images/edit_purple.gif" CssClass="image_button"/>
<asp:ImageButton SkinID="ImageButtonCheckPurple" runat="server" ImageUrl="Images/check_purple.gif" CssClass="image_button"/>
真是气人啊,这种错误查起来还真是不容易。
附1:ASP.NET中的注释符号:
' (single quote)
The single quote character (') introduces a comment line in VB.NET code. It can be used anywhere on a source line. The end of the physical line ends the comment.
Rem
The keyword Rem also introduces a comment in VB.NET code. It can be used anywhere on a source line. The end of the physical line ends the comment.
/* and */
The characters /* and */ open and close respectively a multi-line comment block--the so called regular comment--in C# code. Regular comments can span over a section of a line, a single line, or multiple lines.
//
The double slash characters (//) introduce a one-line comment in C# code and can be placed anywhere on a source line. The one-line comment extends to the end of the line. Equivalent to ' and Rem in VB.NET.
///
The comments introduced by tripple slash characters (///) are a C#-specific feature. By means of XML markup you can document your code (e.g. is used for describing parameters). If you run the compiler with the /doc option, it automatically generates an XML documentation file.
<!-- and -->
The characters <!-- and --> are standard HTML (adopted from SGML) comment delimiters. Note, that the comment text is sent to the browser and thus visible outside (source code).
<%-- and --%>
Server-Side Comments (<%-- --%>) enable ASP.NET page developers to prevent server code (including server controls) and static content from executing/rendering. They assume a similar role to the standard HTML comments with the smashing difference that the text of the comment is not sent to the browser.
The single quote character (') introduces a comment line in VB.NET code. It can be used anywhere on a source line. The end of the physical line ends the comment.
Rem
The keyword Rem also introduces a comment in VB.NET code. It can be used anywhere on a source line. The end of the physical line ends the comment.
/* and */
The characters /* and */ open and close respectively a multi-line comment block--the so called regular comment--in C# code. Regular comments can span over a section of a line, a single line, or multiple lines.
//
The double slash characters (//) introduce a one-line comment in C# code and can be placed anywhere on a source line. The one-line comment extends to the end of the line. Equivalent to ' and Rem in VB.NET.
///
The comments introduced by tripple slash characters (///) are a C#-specific feature. By means of XML markup you can document your code (e.g. is used for describing parameters). If you run the compiler with the /doc option, it automatically generates an XML documentation file.
<!-- and -->
The characters <!-- and --> are standard HTML (adopted from SGML) comment delimiters. Note, that the comment text is sent to the browser and thus visible outside (source code).
<%-- and --%>
Server-Side Comments (<%-- --%>) enable ASP.NET page developers to prevent server code (including server controls) and static content from executing/rendering. They assume a similar role to the standard HTML comments with the smashing difference that the text of the comment is not sent to the browser.
附2:别人因其它原因遇到类似问题的解决方案:
首先可能是你的log满了,解决办法是
保存并清除日志
打开注册表编辑器,将
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\CrashOnAuditFail的键值设置成1
重启服务器
还有可能是Kerberos认证引起的,解决办法是
如果使用Kerberos认证,在命令提示符下运行SetSPN -A HTTP/主机头 服务器主机名
如果不使用,在命令提示符下运行cscript adsutil.vbs set w3svc/NTAuthenticationProviders "NTLM"
保存并清除日志
打开注册表编辑器,将
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\CrashOnAuditFail的键值设置成1
重启服务器
还有可能是Kerberos认证引起的,解决办法是
如果使用Kerberos认证,在命令提示符下运行SetSPN -A HTTP/主机头 服务器主机名
如果不使用,在命令提示符下运行cscript adsutil.vbs set w3svc/NTAuthenticationProviders "NTLM"