FormsAuthenticationUserCollection.Add(FormsAuthenticationUser) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Adds a FormsAuthenticationUser object to the collection.
public:
void Add(System::Web::Configuration::FormsAuthenticationUser ^ user);
public void Add (System.Web.Configuration.FormsAuthenticationUser user);
member this.Add : System.Web.Configuration.FormsAuthenticationUser -> unit
Public Sub Add (user As FormsAuthenticationUser)
Parameters
The FormsAuthenticationUser object to add to the collection.
Exceptions
The FormsAuthenticationUser object already exists in the collection, or the collection is read-only.
Examples
The following code example shows how to use the Add method.
// Using method Add.
// Define the SHA1 encrypted password.
// This example uses the SHA1 algorithm.
// Due to collision problems with SHA1, Microsoft recommends SHA256 or better.
string password =
"5BAA61E4C9B93F3F0682250B6CF8331B7EE68FD8";
// Define the user name.
string userName = "newUser";
// Create the new user.
FormsAuthenticationUser currentUser =
new FormsAuthenticationUser(userName, password);
// Execute the Add method.
formsAuthenticationCredentials.Users.Add(currentUser);
// Update if not locked
if (!authenticationSection.SectionInformation.IsLocked)
{
configuration.Save();
}
' Using method Add.
' Define the SHA1 encrypted password.
' This example uses the SHA1 algorithm.
' Due to collision problems with SHA1, Microsoft recommends SHA256 or better.
Dim password As String = _
"5BAA61E4C9B93F3F0682250B6CF8331B7EE68FD8"
' Define the user name.
Dim userName As String = "newUser"
' Create the new user.
Dim currentUser _
As New FormsAuthenticationUser(userName, password)
' Execute the Add method.
formsAuthenticationCredentials.Users.Add(currentUser)
' Update if not locked
If Not authenticationSection.SectionInformation.IsLocked Then
configuration.Save()
End If
Remarks
The collection must not contain a FormsAuthenticationUser object with the same name.
Applies to
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기