2013-03-01 101 views
1

试图限制匿名用户登录login.aspx,register.aspx和Site.css文件并进行身份验证以访问整个站点。 当前anonymous可以访问login.aspx和Site.css,因为样式显示正确。但是,当我点击register.aspx链接时,我被重定向到login.aspx页面。有权访问register.aspx但被重定向到登录页面的匿名用户

在web根目录下我的web.config。目录结构中没有其他web.configs。我不知道我是否应该寻找其他地方(我知道WSAT有时可以保持规则,但不知道是否被根Web.config取代)。

只是想登录和注册文件引用母版页,这是否也需要明确的授权?虽然不能解释为什么登录工作的匿名,但注册不。

感谢您的帮助!安东尼。

<?xml version="1.0"?> 

<configuration> 
    <connectionStrings> 
    <add name="************" 
     connectionString="Data Source=**********; Initial Catalog=************; Integrated Security=SSPI; Persist Security Info=False; Trusted_Connection=Yes" 
     providerName="System.Data.SqlClient" /> 
    </connectionStrings> 

    <location path="Register.aspx"> 
    <system.web> 
     <authorization> 
     <allow users="?"/> 
     </authorization> 
    </system.web> 
    </location> 

    <location path="Login.aspx"> 
    <system.web> 
     <authorization> 
     <allow users="?"/> 
     </authorization> 
    </system.web> 
    </location> 

    <location path="Site.css"> 
    <system.web> 
     <authorization> 
     <allow users="?"/> 
     </authorization> 
    </system.web> 
    </location> 

    <system.web> 
    <compilation debug="true" targetFramework="4.0" /> 

    <authentication mode="Forms"> 
     <forms loginUrl="~/Website/Login.aspx" timeout="2880" /> 
    </authentication> 

    <authorization> 
     <deny users="?"/> 
    </authorization> 

    <membership> 
     <providers> 
     <clear/> 
     <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" 
      enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" 
      maxInvalidPasswordAttempts="5" minRequiredPasswordLength="8" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" 
      applicationName="***********" /> 
     </providers> 
    </membership> 

    <profile> 
     <providers> 
     <clear/> 
     <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="**********" applicationName="/"/> 
     </providers> 
    </profile> 

    <roleManager enabled="false"> 
     <providers> 
     <clear/> 
     <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="***********" applicationName="/" /> 
     <add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" /> 
     </providers> 
    </roleManager> 
    </system.web> 

    <system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"/> 
    </system.webServer> 
</configuration> 
+0

入住提琴手或'Network'选项卡浏览器的开发工具,这要求!返回401代码 – 2013-03-01 09:14:53

回答

-1

尝试更改包含〜/网站的路径,与您的表单身份验证登录位置相同。您不需要默认指定的登录页面,它允许访问,因为它是您的formsauthentication设置中的LoginUrl。

<location path="~/Website/Register.aspx"> 
    <system.web> 
     <authorization> 
     <allow users="?"/> 
     </authorization> 
    </system.web> 
    </location> 

    <location path="~/Website/Login.aspx"> 
    <system.web> 
     <authorization> 
     <allow users="?"/> 
     </authorization> 
    </system.web> 
    </location> 
+0

谢谢我试过这个,但它没有区别,而且,因为我然后切换回以前的代码,我的样式不再通过 - 不知道是否有发展Web服务器或铬浏览器或asp的缓存问题。 net有时缓存web.configs? – user2122755 2013-03-01 09:40:59

+0

什么是您在浏览器中导航到Reg的确切URL ister页面和登录页面,包括http://? – WDuffy 2013-03-01 09:52:11

+0

http:// localhost:4842/Website/Login.aspx http:// localhost:4842/Website/Register.aspx但是当我点击Register.aspx链接时,我得到这个返回的地址栏:http:// localhost :4842/Website/Login.aspx?ReturnUrl =%2fWebsite%2fRegister.aspx – user2122755 2013-03-01 10:05:11

0

此代码将只允许匿名用户: (注意添加否认节点之后的允许

<location path="Register.aspx"> 
    <system.web> 
     <authorization> 
     <allow users="?"/> 
     <deny users="*" /> 
     </authorization> 
    </system.web> 
    </location> 
相关问题