Search This Blog

Deploying MVC4 website in IIS in Windows Server 2008 R2

First step, publish the website, and then deploy it in IIS.
Error: Forbidden error, directory listing disabled
Solution: Add [module runAllManagedModuleForAllRequests=true]   to web.config under system.webServer node.

 [system.webServer]
    [validation validateIntegratedModeConfiguration="false" /]
[modules runAllManagedModulesForAllRequests="true" /]
........
[system.webServer]


Another option, is not to use this method , instead use
[modules]
  [remove name="UrlRoutingModule-4.0" /]
  [add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" /]
[/modules]

2. Error : Method not found: 'Void System.Data.Objects.ObjectContextOptions.set_UseConsistentNullReferenceBehavior(Boolean)'.

Cause:  using EF 5.0 with .net 4
Since, i was not using EF, i removed it with Nuget. As i created the website with the default Internet application template, it came along with.

3. Oracle Dataaccess inconsistencies
Solution: copied all the oracle odp.net dll to bin.

Turn On/Off Hypervisor from Command Prompt

The necessity of switching the hypervisor aroused when working with virtual box and windows phone.
The hypervisor needs to be turned on when working with projects related to windows phone and needs to be turned off, when working with virtual box or vmware.

For the following purposes, run the command prompt with administrative privileges.

1. Check the status of the hypervisor

Command: "bcdedit /enum
will list the current settings of the 'Windows Boot Manager' & 'Windows boot loader'. Under 'Windows Boot Loader ', check for the setting of 'hypervisorlaunchtype' . It will be 'Off' if it is turned off and 'Auto', if it's turned On.

2. Turn Off the hypervisor
Command: "bcdedit /set hypervisorlaunchtype off"
And restart the system. 

3. Turn On the hypervisor
Command: "bcdedit /set hypervisorlaunchtype auto"
And restart the system


Implementing Oracle-ASP.NET-Provider in C #

Below is the process, how I have implemented the Oracle-ASP.NET-Provider within a ASP.NET web-application.

The first step is to install the latest version of the "Oracle Data Provider for .NET" from the oracle site

Then the next step is to create all the tables required for the Oracle-ASP.NET-Provider. For this, simply run the sql query from the file "InstallAllOracleASPNETProviders.sql" located at "C:\app\[the_computer_name]\product\11.2.0\client_4\ASP.NET\SQL" (considering you have accepted the default location for the installation).

1. Web.config

The web.config of the web-application looks like
[' < ' and ' > ' replaced by ' ( ' and ' ) ']
 Connection String
(add name="OraAspNetConnectionString" connectionString="Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=db_ip)(PORT=db_port))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME = orcl)));User Id=user_db;Password=password_db;pooling=true;min pool size=9" providerName="Oracle.DataAccess.Client"/)
Membership Settings
(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="true"
           passwordFormat="Hashed" maxInvalidPasswordAttempts="10" minRequiredPasswordLength="7"
           minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" passwordStrengthRegularExpression=""  /)
      (/providers)
   (/membership)

Profile Settings
    (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)

Role Settings
    (roleManager enabled="true" defaultProvider ="OracleRoleProvider")
      (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)



 Here the OracleDataAccess.dll of version 2 is being used. 

2. Creating User

 protected void btnCreateUser_Click(object sender, EventArgs e)
        {
            try
            {
                Membership.CreateUser(txtUsername.Text, txtPassword.Text, txtUserEmail.Text);
                txtUsername.Text = "User Created Successfully";
            }
            catch (Exception)
            {
             
                throw;
            }
         
        }

3. Creating Role

protected void btnCreateRole_Click(object sender, EventArgs e)
        {
            String roleName = txtRole.Text.Trim();
            try
            {
                if (!Roles.RoleExists(roleName))
                {
                    Roles.CreateRole(roleName);
                    txtRole.Text = "Role Created Successfully. " + txtRole.Text;
                }
                else
                {
                    txtRole.Text = "Role already exists. " + txtRole.Text;
                }
            }
            catch (Exception ex)
            {
                   throw;
            }
        }

4. Assigning Role to User

protected void btnAddRoleToUser_Click(object sender, EventArgs e)
        {
            try
            {
                Roles.AddUserToRole(txtUser.Text,txtRoleToAdd.Text);
                txtRoleToAdd.Text = "Role added";
            }
            catch (Exception)
            {
             
                throw;
            }
        }

5. User Login

protected void btnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                if (Membership.ValidateUser(txtUserName.Text, txtPassword.Text))
                {
                    FormsAuthentication.SetAuthCookie(txtUserName.Text, true);
                    txtUserName.Text = "success";
                }
                else {
                    txtUserName.Text = "fail";
                }
                 
             
            }
            catch (Exception)
            {
             
                throw;
            }
        }


SecurityNegotiationException WCF

Problem Faced:  created a WCF Service and hosted it in IIS. The client application could communicate with the Service iff it's in the same machine else throws SecurityNegotiationException Exception.

Solution:
Disabled the binding security,

Step1: Right click on the web.config in solution explorer, and select "Edit WCF Configuration"
Step 2: In the endpoint with wsHttpBinding, Create Binding configuration.
Step 3: under security tab, select Mode to None under General section.

ORA-01008: not all variables bound

Sometimes this might be because of the Data Access Provider.
I thought i would increase the data access performance in my application, SO, I changed the data-provider to Oracle.DataAccess.Client and the error occurred, could not figure out the exact reason though, but reverted back to System.Data.OracleClient, and everything worked as previous.

TODO: need to figure it out.