ci sto provando ma ho un errore che non capisco
Questo è il web.config
codice:
<authentication mode="Forms"/>
<membership defaultProvider="AccessMembershipProvider" >
<providers>
<add name="AccessMembershipProvider"
type="AccessMembershipProvider"
requiresQuestionAndAnswer="true"
connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Gege\Documenti\Visual Studio 2008\Projects\Progetto_prova3c\Progetto_prova3c\App_Data\Members.mdb;Persist Security Info=False"
/>
</providers>
</membership>
Il file AccessMembershipProvider.cs inserito in App_Code invece è cosi'
codice:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.OleDb;
using System.Diagnostics;
using System.Web.Security;
using System.Configuration;
namespace Progetto_prova3c
{
public class AccessMembershipProvider : MembershipProvider
{
//---for database access use---
private string connStr;
private OleDbCommand comm;
// private bool _requiresQuestionAndAnswer;
// private int _minRequiredPasswordLength;
public override string ApplicationName
{
get
{
throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
}
}
public override bool ChangePassword(string username, string oldPassword, string newPassword)
{
throw new NotImplementedException();
}
public override bool ChangePasswordQuestionAndAnswer(string username, string password, string newPasswordQuestion, string newPasswordAnswer)
{
throw new NotImplementedException();
}
public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status)
{
throw new NotImplementedException();
}
public override bool DeleteUser(string username, bool deleteAllRelatedData)
{
throw new NotImplementedException();
}
public override bool EnablePasswordReset
{
get { throw new NotImplementedException(); }
}
public override bool EnablePasswordRetrieval
{
get { throw new NotImplementedException(); }
}
public override MembershipUserCollection FindUsersByEmail(string emailToMatch, int pageIndex, int pageSize, out int totalRecords)
{
throw new NotImplementedException();
}
public override MembershipUserCollection FindUsersByName(string usernameToMatch, int pageIndex, int pageSize, out int totalRecords)
{
throw new NotImplementedException();
}
public override MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords)
{
throw new NotImplementedException();
}
public override int GetNumberOfUsersOnline()
{
throw new NotImplementedException();
}
public override string GetPassword(string username, string answer)
{
throw new NotImplementedException();
}
public override MembershipUser GetUser(string username, bool userIsOnline)
{
throw new NotImplementedException();
}
public override MembershipUser GetUser(object providerUserKey, bool userIsOnline)
{
throw new NotImplementedException();
}
public override string GetUserNameByEmail(string email)
{
throw new NotImplementedException();
}
public override int MaxInvalidPasswordAttempts
{
get { throw new NotImplementedException(); }
}
public override int MinRequiredNonAlphanumericCharacters
{
get { throw new NotImplementedException(); }
}
public override int MinRequiredPasswordLength
{
get { throw new NotImplementedException(); }
}
public override int PasswordAttemptWindow
{
get { throw new NotImplementedException(); }
}
public override MembershipPasswordFormat PasswordFormat
{
get { throw new NotImplementedException(); }
}
public override string PasswordStrengthRegularExpression
{
get { throw new NotImplementedException(); }
}
public override bool RequiresQuestionAndAnswer
{
get { throw new NotImplementedException(); }
}
public override bool RequiresUniqueEmail
{
get { throw new NotImplementedException(); }
}
public override string ResetPassword(string username, string answer)
{
throw new NotImplementedException();
}
public override bool UnlockUser(string userName)
{
throw new NotImplementedException();
}
public override void UpdateUser(MembershipUser user)
{
throw new NotImplementedException();
}
public override bool ValidateUser(string username, string password)
{
connStr = ConfigurationManager.ConnectionStrings["AccessMembershipProvider"].ConnectionString;
OleDbConnection conn = new OleDbConnection(connStr);
try
{
conn.Open();
string sql = "Select * From Membership WHERE " + "username=@username AND password=@password";
comm = new OleDbCommand(sql, conn);
comm.Parameters.AddWithValue("@username", username);
comm.Parameters.AddWithValue("@password", password);
OleDbDataReader reader = comm.ExecuteReader(CommandBehavior.CloseConnection);
if (reader.HasRows)
{
return true;
}
else
{
return false;
}
// conn.Close();
}
catch (Exception ex)
{
Console.WriteLine("error");
return false;
}
}
}
}
L'errore che mi da dopo aver fatto un login con un semplice controllo Login è
codice:
Errore di configurazione.
Descrizione: Si è verificato un errore durante l'elaborazione di un file di configurazione necessario per soddisfare la richiesta. Verificare i dettagli dell'errore specifico riportati di seguito e modificare il file di configurazione in modo appropriato.
Messaggio di errore del parser: Impossibile caricare il tipo 'AccessMembershipProvider'.
Errore nel codice sorgente:
Riga 52: <providers>
Riga 53: <add name="AccessMembershipProvider"
Riga 54: type="AccessMembershipProvider"
Riga 55: requiresQuestionAndAnswer="true"
Riga 56: connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Gege\Documenti\Visual Studio 2008\Projects\Progetto_prova3c\Progetto_prova3c\App_Data\Members.mdb;Persist Security Info=False"
File di origine: C:\Documents and Settings\Gege\Documenti\Visual Studio 2008\Projects\Progetto_prova3c\Progetto_prova3c\web.config Riga: 54
A me sembra corretto il type...