登录的用户无效.Memership服务. asp.net
发布时间:2020-12-16 09:34:29 所属栏目:asp.Net 来源:网络整理
导读:我有一个具有登录控件的默认页面,该页面位于主目录中.然后我有一堆页面,我只希望可以查看已登录“MemberPages”目录的人.我的问题是当我点击默认页面上的登录按钮,使用用户名并传递不在数据库中时,它仍然需要我所有的成员页面 我浏览了asp.net配置并设置了“
我有一个具有登录控件的默认页面,该页面位于主目录中.然后我有一堆页面,我只希望可以查看已登录“MemberPages”目录的人.我的问题是当我点击默认页面上的登录按钮,使用用户名并传递不在数据库中时,它仍然需要我所有的成员页面
我浏览了asp.net配置并设置了“MemberPages目录以拒绝所有非auth用户.但它仍然有从主要继承的褪色,允许所有并且无法更改(也许这是问题?但我不能删除它)还有什么?谢谢 这是来自MemberPages目录的web.config. <?xml version="1.0" encoding="utf-8"?> <configuration> <system.web> <authorization> <deny users="?" /> </authorization> </system.web> </configuration> 这是我的主要web.config. <configuration> <connectionStrings> <add name="LoginSQL" providerName="System.Data.SqlClient" connectionString="Data Source=xx.xx.xx.xx;Initial Catalog=xxxx;UID=xxxxxxx ;pwd=xxxxx;"/> </connectionStrings> <system.web> <compilation debug="true" targetFramework="4.0"/> <authentication mode="Forms"> <forms name="Login" loginUrl="Default.aspx" timeout="20" /> </authentication> <membership> <providers> <add connectionStringName="LoginSQL" applicationName="Login" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" requiresUniqueEmail="true" passwordFormat="Hashed" maxInvalidPasswordAttempts="3" passwordAttemptWindow="30" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" name="MySqlLoginProvider" type="System.Web.Security.SqlMembershipProvider" /> </providers> </membership> <profile> <providers> <clear/> <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/> </providers> </profile> <roleManager cacheRolesInCookie="true" cookieName=".ASPRoles" cookieTimeout="60"> <providers> <add connectionStringName="LoginSQL" applicationName="Login" name="MyRoleProvider" type="System.Web.Security.SqlRoleProvider" /> </providers> </roleManager> </system.web> <system.webServer> <modules runAllManagedModulesForAllRequests="true"/> </system.webServer> </configuration> 解决方法
“我的问题是,当我点击默认页面上的登录按钮时,使用用户名和传递不在数据库中,它仍然会将我带到我的所有成员页面.”
从上面的陈述中可以清楚地看出,您没有正确验证用户登录.如果用户/密码不存在,则代码不应将用户重定向到登录页面. 检查登录点击事件处理程序周围的代码.你应该有这样的东西: protected void btnLogin_Click(object sender,EventArgs e) { if (Membership.ValidateUser(txtUserName.Text,txtPassword.Text)) { FormsAuthentication.RedirectFromLoginPage(txtUserName.Text,true); } else { txtLoginFailedMsg.Text = "Login failed. Please check your user name and password and try again."; } } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- ASP.Net Core 2.0和日志记录
- asp.net – 带有nginx或apache的Mono 2.11
- asp.net-mvc – ASP MVC查看内容为JSON
- asp.net-mvc – 在数据库中存储ASP.Net MVC视图
- asp.net-mvc-3 – 实体框架,MVC 3,LINQ To Entities中的Ord
- asp.net – 将特定文件夹映射到web.config中的HttpHandler
- 如何在ASP.NET中运行时更改FormsCookieName
- 在ASP.NET C#中调用Web服务时,Session为null
- asp.net – 如何从HttpResponseMessage获取对象?
- asp.net-mvc – 在ASP.NEt MVC 3中传递Html.BeginForm()中D
推荐文章
站长推荐
- asp.net – SQL Server应用程序角色,性能命中
- asp.net-mvc – 在asp.net mvc中的redirecttoact
- [ASP.NET] iTextSharp产生PDF档...Part_1(把Grid
- asp.net – 在同一个项目的MVC和Web API中使用In
- asp.net – 在MVC 4.0中使用部分视图中的节
- asp.net-mvc – ASP.NET MVC强类型视图与否?
- asp.net-mvc – MVC4 Bootstrap示例中基于角色的
- asp.net-mvc – jQGrid和MVC 3.0 ViewModel
- 【译】使用Jwt身份认证保护 Asp.Net Core Web Ap
- ASP.NET实现二维码
热点阅读