第一次在VS里建立WEB应用程序,之前都是直接新建网站的。
我创建了一个多层的解决方案,如下其中Web文件夹为新建的web应用程序,我在里面配置了webconfig,其实是从另一网站直接拷过来的,如下<?xml version="1.0" encoding="utf-8"?><!--
  有关如何配置 ASP.NET 应用程序的详细消息,请访问
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<!--<?xml version="1.0" encoding="UTF-8"?>
    注意: 除了手动编辑此文件外,您还可以使用 
    Web 管理工具来配置应用程序的设置。可以使用 Visual Studio 中的
    “网站”->“Asp.Net 配置”选项。
    有关设置和注释的完整列表可以在
    machine.config.comments 中找到,该文件通常位于
      \Windows\Microsoft.Net\Framework\vx.x\Config 中 
-->
<configuration>
    <appSettings>
        <add key="ConnectionString" value="server=(local);Uid=sa;pwd=tc13376543186;database=DBFlower;" />
    </appSettings>
    <connectionStrings>
        <remove name="LocalSqlServers" />
        <add connectionString="Data Source=JY-PC;Initial Catalog=aspnetdb;User ID=sa;Password=tc13376543186" name="LocalSqlServers" />
        <add connectionString="Data Source=JY-PC;Initial Catalog=MyProfile;User ID=sa;Password=tc13376543186" name="ProfileService" />
        <!--<add name="memberConnectionString" connectionString="Data Source=(local);Integrated Security=SSPI;Initial Catalog=aspnetdb;User ID=sa;"/>-->
    </connectionStrings>
    <system.web>
        <!-- 
            设置 compilation debug="true" 可将调试符号插入到
            已编译的页面。由于这会
            影响性能,因此请仅在开发过程中将此值
            设置为 true。
        -->
        <roleManager enabled="true" defaultProvider="CustomSqlprovider" cacheRolesInCookie="true" cookieName=".MyRolesCookie" cookieTimeout="30" cookieSlidingExpiration="false" cookieProtection="All">
            <providers>
                <add name="CustomSqlprovider" type="System.Web.Security.SqlRoleProvider" connectionStringName="LocalSqlServers" applicationName="k" />
            </providers>
        </roleManager>
        <compilation debug="true" targetFramework="4.0">
            <assemblies>
                <add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
            </assemblies>
        </compilation>
        <!--
          通过 <authentication> 节可以配置
          安全身份验证模式,ASP.NET 
          使用该模式来识别来访用户身份。 
        -->
        <authentication mode="Forms">
            <forms name="AuthCookie" loginUrl="login.html" />
        </authentication>
        <membership defaultProvider="MyMembershipProvider">
            <providers>
                <add connectionStringName="LocalSqlServers" applicationName="as" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" requiresUniqueEmail="true" passwordFormat="Hashed" name="MyMembershipProvider" type="System.Web.Security.SqlMembershipProvider" />
                <add connectionStringName="LocalSqlServers" applicationName="/" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" requiresUniqueEmail="true" passwordFormat="Hashed" name="MyMembershipProvider2" type="System.Web.Security.SqlMembershipProvider" />
            </providers>
        </membership>
        <profile defaultProvider="FactoredProfileProvider">
            <providers>
                <clear />
                <add connectionStringName="LocalSqlServers" applicationName="as" name="MySqlProvider" type="System.Web.Profile.SqlProfileProvider" />
                <add name="FactoredProfileProvider"
                     type="FactoredProfileProvider"
                     connectionStringName="ProfileService"
                     updateUserProcedure="Users_Update"
                     getUserProcedure="Users_GetByUserName"/>
            </providers>
            <properties>
                <add name="AddressName" type="String" provider="FactoredProfileProvider"/>
                <add name="AddressCountry" type="String" provider="FactoredProfileProvider"/>
            </properties>        </profile>
        <authorization>
            <!--设置资源为受保护,匿名不允许访问-->
            <deny users="?" />
            
        </authorization>
        <!--
           如果在执行请求的过程中出现未处理的错误,
           则通过 <customErrors> 节
           可以配置相应的处理步骤。具体而言,
           开发人员通过该节可配置要显示的 html 错误页,
           以代替错误堆栈跟踪。           <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
             <error statusCode="403" redirect="NoAccess.htm" />
             <error statusCode="404" redirect="FileNotFound.htm" />
           </customErrors>
        -->
        <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID" />
    </system.web>
    <system.webServer>
        <!--<modules runAllManagedModulesForAllRequests="true">
            -->
        <!--将 runAllManagedModulesForAllRequests 属性设置为 true。
            这样做的效果是:替代 IIS 配置存储区中的“managedHandler”预设条件集,
            并由此将管道的托管代码部分(包括那些由 ASP.NET 提供的托管代码部分,例如用户身份验证)应用于所有请求,
            而不论已请求的资源是否属于托管类型,也不论它是否与 ASP.NET 具有任何特定关联。-->
        <!--
            <remove name="FormsAuthentication"/>
            <add name="FormsAuthentication"
                 type="System.Web.Security.FormsAuthenticationModule"
                 preCondition=""/>
        </modules>-->
        <modules>
            <remove name="FormsAuthentication" />
            <add name="FormsAuthentication" type="System.Web.Security.FormsAuthenticationModule" preCondition="" />
            <remove name="UrlAuthorization" />
            <add name="UrlAuthorization" type="System.Web.Security.UrlAuthorizationModule" preCondition="" />
            <!--<remove name="DefaultAuthentication" />
            <add name="DefaultAuthentication" type="System.Web.Security.DefaultAuthenticationModule" preCondition=""/>-->--&gt;
        </modules>
        <security>
            <authorization>
                <add accessType="Deny" roles="user2" />
            </authorization>
        </security>
    </system.webServer>
    <!--允许特定页访问-->
    <location path="allow">
        <system.web>
            <authorization>
                <allow users="*" />
            </authorization>
        </system.web>
    </location>
    <location path="css">
        <system.web>
            <authorization>
                <allow users="?"/>
            </authorization>
        </system.web>
    </location>
    <location path="script">
        <system.web>
            <authorization>
                <allow users="?"/>
            </authorization>
        </system.web>
    </location>
    <!-- 
        system.webServer 节是在 Internet Information Services 7.0 下运行 ASP.NET AJAX
        所必需的。对早期版本的 IIS 来说则不需要此节。
    -->
</configuration>
用了表单验证,匿名跳转到login。html,在VS里运行正常,在IIS里,我是直接新建一个站点,物理路径是包含上面多个项目的文件夹,第一次运行后不跳转。于是,我选中web文件夹,也就是那个web应用程序,然后单击模块设置,结果弹出 “不允许在应用程序下配置节” 郁闷了半天,最后把那个Web文件夹右键转换为应用程序(它本身不就是web应用程序吗?),这次再点击模块设置就没问题了,然后访问界面,嗯,可以成功跳转,但是!javascript失效了,还有部分css也失效!到底要怎么办啊?有经验的能给出一个合理的解决方案吗?(ps,在没把Web文件夹右键转换为应用程序前,js和CSS都可以正常运行,而且我已经很注意把他们标为可访问资源了,web.config可看出),再次求高手帮小弟脱困.