所以我得到了2个.aspx文件。一个叫login,一个叫default。这个想法是,当你启动应用程序时,你将被踢到登录屏幕。我与在default.aspx.vb文件下面的代码这样做:asp.net授权问题授权所有人
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
If (HttpContext.Current.User.Identity.IsAuthenticated = False) Then
Response.Redirect("Login.aspx")
End If
End Sub
问题是,你总是验证的某些原因。它总是返回true。 我的Web配置文件看起来像这样:
<configuration>
<appSettings>
<add key="strConn" value="EDITED"/>
</appSettings>
<location path="~/Styles">
<system.web>
<customErrors mode ="Off">
</customErrors>
<authentication mode="Forms">
<forms name=".ASPXAUTH"
loginUrl="Login.aspx"
protection="All"
timeout="30"
path="/">
</forms>
</authentication>
<authorization>
<deny users="?" />
<allow users="*" />
</authorization>
<compilation debug="true" strict="false" explicit="true" targetFramework="4.0">
<assemblies>
<add assembly="Microsoft.Data.Odbc, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="system.web.security"/>
</assemblies>
</compilation>
</system.web>
</location>
</configuration>
我已经试过藏汉没有改变任何东西。用户通过数据库进行身份验证。目前我正在Visual Studio中运行该程序,而不是在我的网站上运行。当用户通过数据库检查时,我使用下面的代码:
FormsAuthentication.RedirectFromLoginPage(txtUserName.Text, chkPersistCookie.Checked)
那么任何想法为什么人们总是被授权? 。
那它应该在哪里?我现在没有视觉工作室。但我会测试明天。你能告诉我位置标签通常放在哪里吗? – 2011-03-12 19:09:01
您应该只是删除位置标记。你在做的是说所有这些设置只适用于Styles目录。我无法想象这就是你想要的。 – joelt 2011-03-12 20:12:36
嗯,但现在我的所有文件都丢失了CSS,好消息是,现在一切正常,经过1星期的努力才发现,这只是一个愚蠢的位置标记..:p神感觉很好=) – 2011-03-12 21:06:05