关于 web.config

guoyan19811021 2003-04-21 08:40:55
我使用表单认证,可以实现访问页面的权限,当没有通过验证,自动跳转到log页面。但,通过验证也自动跳转到log页?为什么?使用FormsAuthentication.RedirectFromLoginPage,怎么提示我未定义?
...全文
40 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
saucer 2003-04-22
  • 打赏
  • 举报
回复
没法给你调试,所以建议你从quickstart的样品程序试起
http://samples.gotdotnet.com/quickstart/aspplus/doc/formsauth.aspx
saucer 2003-04-22
  • 打赏
  • 举报
回复
你的用法
FormsAuthentication.RedirectFromLoginPage(txtUsername.text, PersistCookie.Checked);
是对的
guoyan19811021 2003-04-22
  • 打赏
  • 举报
回复
谢谢saucer, 原来我没有引用命名空间 Imports System.Web.Security,现在好了,不过
到底怎么使用FormsAuthentication.RedirectFromLoginPage
saucer 2003-04-22
  • 打赏
  • 举报
回复
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
guoyan19811021 2003-04-22
  • 打赏
  • 举报
回复
to:saucer
可不可以详细点?谢谢
saucer 2003-04-22
  • 打赏
  • 举报
回复
1. make sure it indeed executes FormsAuthentication.RedirectFromLoginPage

2. the following code looks suspicious

<authorization>
<allow users="*" />
</authorization>


should be

<authorization>
<deny users="?" />
</authorization>
??
guoyan19811021 2003-04-22
  • 打赏
  • 举报
回复
但是,却不能实现。通过验证也自动跳转到log页?为什么?
guoyan19811021 2003-04-21
  • 打赏
  • 举报
回复
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
saucer 2003-04-21
  • 打赏
  • 举报
回复
show your code or take a look at an example

http://samples.gotdotnet.com/quickstart/aspplus/doc/formsauth.aspx
暗石绿 2003-04-21
  • 打赏
  • 举报
回复
FormsAuthentication.RedirectFromLoginPage(username,false);//不永久保存cookie
FormsAuthentication.RedirectFromLoginPage(username,true);//保存cookie 50 年
xunx 2003-04-21
  • 打赏
  • 举报
回复
^_^

62,047

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧