关于 web.config
我使用表单认证,可以实现访问页面的权限,当没有通过验证,自动跳转到log页面。但,通过验证也自动跳转到log页?为什么?使用FormsAuthentication.RedirectFromLoginPage,怎么提示我未定义? 问题点数:80、回复次数:13Top
1 楼xunx()回复于 2003-04-21 20:51:00 得分 0
^_^Top
2 楼xrascal(横刀夺爱)回复于 2003-04-21 20:53:13 得分 0
FormsAuthentication.RedirectFromLoginPage(username,false);//不永久保存cookie
FormsAuthentication.RedirectFromLoginPage(username,true);//保存cookie 50 年Top
3 楼saucer(思归)回复于 2003-04-21 20:54:33 得分 0
show your code or take a look at an example
http://samples.gotdotnet.com/quickstart/aspplus/doc/formsauth.aspxTop
4 楼guoyan19811021(吉祥)回复于 2003-04-21 21:37:43 得分 0
to:saucer
web.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<compilation defaultLanguage="vb" debug="true" />
<customErrors mode="Off" />
<authentication mode="Forms">
<forms name="FormAuthentication" path="/" loginUrl="log_pxb.aspx" />
</authentication>
<authorization>
<allow users="*" />
</authorization>
<trace enabled="false" requestLimit="10" pageOutput="false" traceMode="SortByTime" localOnly="true" />
<sessionState
mode="InProc"
stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data source=127.0.0.1;user id=sa;password="
cookieless="false"
timeout="20"
/>
<globalization requestEncoding="utf-8" responseEncoding="utf-8" />
</system.web>
<location path="main">
<system.web>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</location>
</configuration>
然后在log_pxb.aspx:
Try
If functions.GetReaderObject("SELECT Members.Username, Members.Password FROM (Members) WHERE (((Members.Username)='" & txtusername.Text & "') AND ((Members.Password)='" & txtpassword.Text & "'));", Page.MapPath("db/db.mdb")).Read Then
Response.Write("<script>window.open('mainpage_pxb.htm','newin','dialogheight:600px;dialogwidth:800px;edge:raised;center:yes;resizeable:no;status:no;');</script>")
'关闭窗口
Response.Write("<script>javascript:self.close();</script>")
'Response.Write("<script> window.open('mainyemian.htm?id={0}', '_blank', 'scrollbars=yes,center=yes, width=900, height=700');</script>")
Dim stase As String
'设置会话状态
Session("stase") = txtusername.Text
'提示未定义
FormsAuthentication.RedirectFromLoginPage(txtUsername.text, PersistCookie.Checked);
Else
Response.Write("<script>alert('你输入的用户名或密码错误!');</script>")
txtusername.BackColor = Color.DarkBlue
txtusername.ForeColor = Color.White
End If
Catch objexception As Exception
Response.Write("<script>alert('objexcepotion.message');</script>")
End Try
Top
5 楼saucer(思归)回复于 2003-04-22 02:25:56 得分 80
1. make sure it indeed executes FormsAuthentication.RedirectFromLoginPage
2. the following code looks suspicious
<authorization>
<allow users="*" />
</authorization>
should be
<authorization>
<deny users="?" />
</authorization>
??
Top
6 楼guoyan19811021(吉祥)回复于 2003-04-22 08:48:26 得分 0
to:saucer
可不可以详细点?谢谢Top
7 楼saucer(思归)回复于 2003-04-22 08:54:43 得分 0
I have no idea if your functions.GetReaderObject(...) works well
I would sugget you to follow the sample at
http://samples.gotdotnet.com/quickstart/aspplus/doc/formsauth.aspx
and adding code from there
Top
8 楼guoyan19811021(吉祥)回复于 2003-04-22 09:33:18 得分 0
谢谢saucer, 原来我没有引用命名空间 Imports System.Web.Security,现在好了,不过
到底怎么使用FormsAuthentication.RedirectFromLoginPageTop
9 楼saucer(思归)回复于 2003-04-22 09:38:03 得分 0
你的用法
FormsAuthentication.RedirectFromLoginPage(txtUsername.text, PersistCookie.Checked);
是对的Top
10 楼guoyan19811021(吉祥)回复于 2003-04-22 14:03:20 得分 0
但是,却不能实现。通过验证也自动跳转到log页?为什么?Top
11 楼saucer(思归)回复于 2003-04-22 22:00:57 得分 0
没法给你调试,所以建议你从quickstart的样品程序试起
http://samples.gotdotnet.com/quickstart/aspplus/doc/formsauth.aspxTop





