c# - 在 Web 表单中的自定义配置文件提供程序上从用户获取和设置数据
问题描述
我一直在阅读一些教程,并创建了以下类,以便我可以获取用户数据并将其存储并在经过身份验证后随时在应用程序中访问它
using System;
using System.Configuration;
using System.Web;
using System.Web.Profile;
namespace FolhaRegisto.Models
{
public class CustomProfileProvider : ProfileProvider
{
public override int DeleteInactiveProfiles(ProfileAuthenticationOption authenticationOption, DateTime userInactiveSinceDate)
{
throw new NotImplementedException();
}
public override int DeleteProfiles(string[] usernames)
{
throw new NotImplementedException();
}
public override int DeleteProfiles(ProfileInfoCollection profiles)
{
throw new NotImplementedException();
}
public override ProfileInfoCollection FindInactiveProfilesByUserName(ProfileAuthenticationOption authenticationOption, string usernameToMatch, DateTime userInactiveSinceDate, int pageIndex, int pageSize, out int totalRecords)
{
throw new NotImplementedException();
}
public override ProfileInfoCollection FindProfilesByUserName(ProfileAuthenticationOption authenticationOption, string usernameToMatch, int pageIndex, int pageSize, out int totalRecords)
{
throw new NotImplementedException();
}
public override ProfileInfoCollection GetAllInactiveProfiles(ProfileAuthenticationOption authenticationOption, DateTime userInactiveSinceDate, int pageIndex, int pageSize, out int totalRecords)
{
throw new NotImplementedException();
}
public override ProfileInfoCollection GetAllProfiles(ProfileAuthenticationOption authenticationOption, int pageIndex, int pageSize, out int totalRecords)
{
throw new NotImplementedException();
}
public override int GetNumberOfInactiveProfiles(ProfileAuthenticationOption authenticationOption, DateTime userInactiveSinceDate)
{
throw new NotImplementedException();
}
public override string ApplicationName
{
get
{
throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
}
}
public override SettingsPropertyValueCollection GetPropertyValues(SettingsContext context, SettingsPropertyCollection collection)
{
throw new NotImplementedException();
}
public override void SetPropertyValues(SettingsContext context, SettingsPropertyValueCollection collection)
{
throw new NotImplementedException();
}
}
}
这是数据库,我想设置并获取 ProfileProvider 电子邮件,以便在用户通过身份验证时可以随时访问它。
CREATE TABLE hUtilizadores
(
Id INT IDENTITY PRIMARY KEY,
Username NVARCHAR(8) NOT NULL,
Password NVARCHAR(100) NOT NULL,
Acesso NVARCHAR(10) NOT NULL
)
CREATE TABLE hColaboradores
(
IdUser INT UNIQUE NOT NULL,
Nome NVARCHAR(100) NOT NULL,
Email NVARCHAR(100) NOT NULL
)
ALTER TABLE hColaboradores
ADD CONSTRAINT FK_hColaboradores_hUtilizadores
FOREIGN KEY (IdUser)
REFERENCES hUtilizadores(Id)
在网络配置中我有这个
<profile>
<providers>
<add
name="CustomProfileProvider"
type="FolhaRegisto.Models.CustomProfileProvider"
connectionStringName="GestaoRequisicoes" />
</providers>
</profile>
因为关于 Web 表单的自定义配置文件提供程序的信息非常有限,所以我找不到任何明确的示例来说明如何在配置文件上获取数据和存储以及在哪里进行数据库调用我不知道我必须实现哪些功能以及在哪里我从数据库中获取数据
解决方案
推荐阅读
- git - git sparse checkout - 无法中止合并
- python - 如果找到某些文件,如何简单地浏览目录和子目录并创建存档
- sccm - System Center Configuration Manager 无法在域中找到用户或设备
- reactjs - 具有功能组件道具的动态样式组件
- jquery - 如何根据选择的选项在 tr 中添加输入字段 Jquery
- java - 使用相同的 appender 回溯几个记录器
- ruby-on-rails - 我可以在really_destroy 之后重新创建一个对象!它 ?我不想恢复它,而是用相同的电子邮件创建一个新对象
- python - 将 R GET 方法转换为 Python
- json - 如何使用 Jackson ObjectMapper 转义无效的 Mongo 字段名称字符?
- java - Firebase 数据库快照以动态回收查看数组列表