Using membership with Oracle database in ASP.NET MVC 3

Before you do it you need setup and configure Oracle Providers for ASP.NET. You can do this follow by link: http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10767/installation.htm#BEGIN

After installation and configuration are success, we will do following:

1. Create a new ASP.NET MVC 3 project

The default App uses an AspNetSqlMembershipProvider when we create a new project. We can see them in Web.config file.

2. Edit the Web.config by follow code:

Edit connection string

<connectionStrings>
	<add name="OraAspNetConnectionString" connectionString="data source=XE; User Id= ASPNET_DB_USER; Password= ****;"
		providerName="Oracle.DataAccess.Client" />
</connectionStrings>

Next edit membership in <system.web/>

<membership defaultProvider="OracleMembershipProvider">
  <providers>
	<clear/>
	<add name="OracleMembershipProvider" type="Oracle.Web.Security.OracleMembershipProvider, Oracle.Web, Version=2.111.6.20, Culture=neutral, PublicKeyToken=89b483f429c47342"
		 connectionStringName="OraAspNetConnectionString" applicationName="" enablePasswordRetrieval="false"
		 enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false"
		 passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7"
		 minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" passwordStrengthRegularExpression=""  />
  </providers>
</membership>

<profile>
  <providers>
	<clear/>
	<add name="OracleProfileProvider" type="Oracle.Web.Profile.OracleProfileProvider, Oracle.Web, Version=2.111.6.20, Culture=neutral, PublicKeyToken=89b483f429c47342"
		 connectionStringName="OraAspNetConnectionString" applicationName="/"/>
  </providers>
</profile>

<roleManager enabled="false">
  <providers>
	<clear/>
	<add name="OracleRoleProvider" type="Oracle.Web.Security.OracleRoleProvider, Oracle.Web, Version=2.111.6.20, Culture=neutral, PublicKeyToken=89b483f429c47342"
		 connectionStringName="OraAspNetConnectionString" applicationName="/" />
	<add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
  </providers>
</roleManager>

3. Build and Run website

4. Click “Logon” on website

5. Click “Register” to Register user.

6. Check in Oracle database

Advertisements
This entry was posted in ASP.NET MVC. Bookmark the permalink.

5 Responses to Using membership with Oracle database in ASP.NET MVC 3

  1. Teamwild says:

    A nice, easy to follow tutorial. Thanks.
    I did have a few issues with the connection string and ended up having to use something like this:
    connectionString=”Data Source=:/;Persist Security Info=True;User ID=OraAsp;Password=*****;”

    Replacing the Server Name, Port and Service will give you a connection string like:
    connectionString=”Data Source=svr56:1521/TCO1103;Persist Security Info=True;User ID=OraAsp;Password=*****;”

  2. Ricardo says:

    Hi thanks for this import information
    i have a question can i make this for all aplication? map classes with entity framework

  3. Nhật says:

    Why I always have message

    Account creation was unsuccessful. Please correct the errors and try again.

    The password retrieval answer provided is invalid. Please check the value and try again.

  4. Nhật says:

    if I use postgresql then how correct file web.config
    Thanks

  5. Touti says:

    hello thanks for the great tutorial,
    my question is :
    i hove more than one modal in my application i’m using code first migrations
    and i want to run the migration to oracle what should i do.
    thanks in advance.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s