问题是这样的
<authentication mode="Forms">
        <forms loginUrl="Login.aspx" name=".ASPXAUTH" defaultUrl="Default.aspx"></forms>
      </authentication>
      <authorization>
        <deny users="?"></deny>
      </authorization>
以上是在form验证里要用到的配置文件
下面是html
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
   <script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
   
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
        <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="登 陆"  OnClientClick="return confirm('确定要登陆!');"/>
    
    </div>
    </form>
</body>
</html>
<script type="text/javascript">
    $(function() {
        alert("ok");
    });
</script>
以上运行的时候,那个老提示脚本有错误,错误代码如下:
 $(function() {
        alert("ok");
    });

当我把<deny users="?"></deny>这一行代码注释后就正常了
这个问题我昨天搞了一下午都没有解决
想请各位高手帮忙解决一下,拜托各位了。

解决方案 »

  1.   

    <script type="text/javascript">
      $(function() {
            alert("ok");
        }); </script>   js 代码 是由客户端的浏览器解释执行的,跟你服务端的配置没啥关系的,还是检查一下你的js 代码吧
      

  2.   

    是不是想要写成这样的?
    $(document).ready(function(){alert("ok");});
      

  3.   

    那个$(function() { 
            alert("ok"); 
        });这是
    $(document).ready(function(){alert("ok");});的简写
    我赶确定代码绝对不会有问题
    我感觉是那个form机制的影响jquery
      

  4.   

    这时因为加了 <deny users="?">以后,对js文件的访问就必须通过验证后才可以,在验证前是访问不到的。在web.config的最后加一段(和system.web节是同级的): <location path="*.js">
    <system.web>
    <authorization>
    <allow users="*"/>
    </authorization>
    </system.web>
    </location>
      

  5.   

    错误 2 <location> 路径属性必须为相对虚拟路径。它不能包含“?”、“:”、“\”、“*”、“"”、“<”、“>”或“|”中的任何一个。 E:\project\asp.net\FormLogin\web.config 13
    <location path="*.js">
      

  6.   

    哦,是我搞错了
    13行改成改成下面这样试下
      <location path="js">
      

  7.   

    <?xml version="1.0"?>
    <!-- 
        注意: 除了手动编辑此文件以外,您还可以使用 
        Web 管理工具来配置应用程序的设置。可以使用 Visual Studio 中的
         “网站”->“Asp.Net 配置”选项。
        设置和注释的完整列表在 
        machine.config.comments 中,该文件通常位于 
        \Windows\Microsoft.Net\Framework\v2.x\Config 中
    -->
    <configuration>
    <appSettings/>
    <connectionStrings/>
        <system.web>
          <!-- 
                设置 compilation debug="true" 可将调试符号插入
                已编译的页面中。但由于这会 
                影响性能,因此只在开发过程中将此值 
                设置为 true。
            -->
          <compilation debug="true">
          </compilation>
          <!--
                通过 <authentication> 节可以配置 ASP.NET 用来 
                识别进入用户的
                安全身份验证模式。 
            -->
         
          <!--
                如果在执行请求的过程中出现未处理的错误,
                则通过 <customErrors> 节可以配置相应的处理步骤。具体说来,
                开发人员通过该节可以配置
                要显示的 html 错误页
                以代替错误堆栈跟踪。        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
                <error statusCode="403" redirect="NoAccess.htm" />
                <error statusCode="404" redirect="FileNotFound.htm" />
            </customErrors>
            -->
        </system.web>
      <location path="js">
        <system.web>
          <authentication mode="Forms">
            <forms loginUrl="Login.aspx" name=".ASPXAUTH" defaultUrl="Default.aspx"></forms>
          </authentication>
          <authorization>
            <deny users="?"></deny>
          </authorization>
        </system.web>
      </location>
    </configuration>现在提示
    错误 2 在应用程序级别之外使用注册为 allowDefinition='MachineToApplication' 的节是错误的。如果在 IIS 中没有将虚拟目录配置为应用程序,则可能导致此错误。 E:\project\asp.net\FormLogin\web.config 43
    我现在用的是XP目前是没有装IIS
    这个错误 怎么解决
      

  8.   

    你 jquery-1.3.2.min.js 文件也放在里面了? 哎
      

  9.   

    我的jquery文件放在项目/js/jquery-1.3.2.min.js里
      

  10.   


    不要在location配置节里写authentication,
    把它恢复成你原来的样子(放回原先的system.web中)
    然后在web.config下面加上这几句(只需要加这几句,不要其它的)
    <location path="js">
            <system.web>
                <authorization>
                    <allow users="*"/>
                </authorization>
            </system.web>
        </location>
      

  11.   

    <?xml version="1.0"?>
    <!-- 
        注意: 除了手动编辑此文件以外,您还可以使用 
        Web 管理工具来配置应用程序的设置。可以使用 Visual Studio 中的
         “网站”->“Asp.Net 配置”选项。
        设置和注释的完整列表在 
        machine.config.comments 中,该文件通常位于 
        \Windows\Microsoft.Net\Framework\v2.x\Config 中
    -->
    <configuration>
    <appSettings/>
    <connectionStrings/>
        <system.web>
          <!-- 
                设置 compilation debug="true" 可将调试符号插入
                已编译的页面中。但由于这会 
                影响性能,因此只在开发过程中将此值 
                设置为 true。
            -->
          <compilation debug="true">
          </compilation>
          <!--
                通过 <authentication> 节可以配置 ASP.NET 用来 
                识别进入用户的
                安全身份验证模式。 
            -->
          <authentication mode="Forms">
            <forms loginUrl="Login.aspx" name=".ASPXAUTH" defaultUrl="Default.aspx"></forms>
          </authentication>
          <!--
                如果在执行请求的过程中出现未处理的错误,
                则通过 <customErrors> 节可以配置相应的处理步骤。具体说来,
                开发人员通过该节可以配置
                要显示的 html 错误页
                以代替错误堆栈跟踪。        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
                <error statusCode="403" redirect="NoAccess.htm" />
                <error statusCode="404" redirect="FileNotFound.htm" />
            </customErrors>
            -->
        </system.web>
      <location path="js">
        <system.web>
          <authorization>
            <deny users="?"></deny>
          </authorization>
        </system.web>
      </location>
    </configuration>
    按你说的我改了,还是把那个JS的错误
      

  12.   

    你还是没有改对啊<?xml version="1.0"?>
    <!--
        注意: 除了手动编辑此文件以外,您还可以使用
        Web 管理工具来配置应用程序的设置。可以使用 Visual Studio 中的
        “网站”->“Asp.Net 配置”选项。
        设置和注释的完整列表在
        machine.config.comments 中,该文件通常位于
        \Windows\Microsoft.Net\Framework\v2.x\Config 中
    -->
    <configuration>
    <appSettings/>
    <connectionStrings/>
    <system.web>
    <!--
                设置 compilation debug="true" 可将调试符号插入
                已编译的页面中。但由于这会
                影响性能,因此只在开发过程中将此值
                设置为 true。
            -->
    <compilation debug="true">
    </compilation>
    <!--
                通过 <authentication> 节可以配置 ASP.NET 用来
                识别进入用户的
                安全身份验证模式。
            -->
    <authentication mode="Forms">
    <forms loginUrl="Login.aspx" name=".ASPXAUTH" defaultUrl="Default.aspx"> </forms>
    </authentication> <authorization>
    <deny users="?"> </deny>
    </authorization>

    <!--
                如果在执行请求的过程中出现未处理的错误,
                则通过 <customErrors> 节可以配置相应的处理步骤。具体说来,
                开发人员通过该节可以配置
                要显示的 html 错误页
                以代替错误堆栈跟踪。        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
                <error statusCode="403" redirect="NoAccess.htm" />
                <error statusCode="404" redirect="FileNotFound.htm" />
            </customErrors>
            -->
    </system.web>
    <location path="js">
    <system.web>
    <authorization>
    <allow users="*"/>
    </authorization>
    </system.web>
    </location>
    </configuration>原理是先限制对所有文件的未授权访问,然后再对js目录“挖个洞”,让这个目录下的文件不用身份验证就可访问