Sunday 22 March 2015

The cockroach theory for self development - The Persuit Of Happyness


At a restaurant, a cockroach suddenly flew from somewhere and sat on a lady. She started screaming out of fear. With a panic stricken face and trembling voice,she started jumping, with both her hands desperately trying to get rid of the cockroach. Her reaction was contagious, as everyone in her group also got panicky. The lady finally managed to push the cockroach away but ...it landed on another lady in the group.

Now, it was the turn of the other lady in the group to continue the drama. The waiter rushed forward to their rescue. In the relay of throwing, the cockroach next fell upon the waiter. The waiter stood firm, composed himself and observed the behavior of the cockroach on his shirt. When he was confident enough, he grabbed it with his fingers and threw it out of the restaurant.

Sipping my coffee and watching the amusement, the antenna of my mind picked up a few thoughts and started wondering, was the cockroach responsible for their histrionic behavior?
If so, then why was the waiter not disturbed? He handled it near to perfection, without any chaos. It is not the cockroach, but the inability of the ladies to handle the disturbance caused by the cockroach that disturbed the ladies.

I realized that, it is not the shouting of my father or my boss or my wife that disturbs me, but it's my inability to handle the disturbances caused by their shouting that disturbs me. It's not the traffic jams on the road that disturbs me, but my inability to handle the disturbance caused by the traffic jam that disturbs me. More than the problem, it's my reaction to the problem that creates chaos in my life.

Lessons learnt from the story: I understood, I should not react in life. I should always respond. The women reacted, whereas the waiter responded. Reactions are always instinctive whereas responses are always well thought of. A beautiful way to understand............LIFE.
Person who is HAPPY is not because Everything is RIGHT in his Life.. He is HAPPY because his Attitude towards Everything in his Life is Right..!!,,,,,,,
Really beautiful

Friday 20 March 2015

Thursday 19 March 2015

Wednesday 11 February 2015

HTTP Error 500-22 - Internal Server Error The page cannot be displayed because an internal server error has occurred



Now At 11:47 PM I am going to write about how to solve HTTP 500.22 - Internal Server Error . This error is really very Bad Boy . It only display Error Message and does not give any detailed information about error as we don't normally allow for that . So Now I am going to give information how today Solved this error and what will be sure short and easy steps to solve this error so that you save your time .

I First tried to set CustomErrors="Off" in web.congig file just after <system.web> tag start But it does not helped so first i need to find way to see the error . So only way to see the error is through log file . I was using azure so I decided to turn on azure logging to check what is error

Enable Logging In Microsoft Azure Portal -


- Enable Application Diagnostics Logging 


1. Login to Azure Portal . In sidebar click on websites . Click on desired website
2. Now click on configure In Top Menu and scroll down and find 'Application Diagnostics'
3. Once found Do configuration as shown below -

Application Diagnostics For Application Logging - Windows Azure
Application Diagnostics For Application Logging - Windows Azure

- Enable Web Server Logging 


1. Login to Azure Portal . In sidebar click on websites . Click on desired website
2. Now click on configure In Top Menu and scroll down and find 'Web Server Logging'
3. Once found Do configurations as shown below -

Web Server Logging - Windows Azure
Web Server Logging - Windows Azure

4. After Doing Both Diagnostics Configuration . you must Save and Restart Azure Website .

How To Find Error In Azure Website Log


1. Now after Enabling Log you can see your log by logging in your FTP Client like CuteFTP or      FileZilla( In my case) . First login to your FTP Client of that website

2. Now at root you can see a folder named LogFiles as shown below -

LogFile In windows Azure
LogFile In windows Azure


3. Open the folder and then find a folder named 'DetailedErrors' Now open the folder here you can 4. see all your errors details for that particular website . as shown below -



Azure Website Log File Detailed Errors
Azure Website Log File Detailed Errors


5. So choose the latest file and download it to your computer and open it in browser and It will show you error in your azure website in Detail so that we can know error information to solve the error . In my case error was HTTP Error 500.22 error as shown by log file below snapshot -


Find Error Using Logs in windows Azure
Find Error Using Logs in windows Azure


 Cause of  HTTP Error 500-22 - Internal Server Error


The Main cause of  "HTTP Error 500-22 - Internal Server Error  The page cannot be displayed because an internal server error has occurred" is Managed Pipeline Mode in Application Pool . Integrated Pipeline Mode of Application Pool does not support some services and functionalities 

Solution For HTTP Error 500-22 - Internal Server Error  


Step 1- Change Application Pool From Integrated Pipeline Mode To Classic Pipeline Mode


FOR IIS USERS ON Windows Server


1. Open Control Panel Then GoTo Administrative Tools
2. Then choose IIS Manager
3. Now Change  App site's Managed Pipeline from Integrated to Classic.

FOR AZURE PORTAL USERS 


1. Login to your Azure Portal . In sidebar click on websites . Click on desired website
2. Now click on configure In Top Menu and Under General Section find 'Managed Pipeline Mode'
3. Once Found Change mode from Integrated To Classic Pipeline Mode  as shown in snapshot below

Enable Classic Pipeline Mode Application Pool IIS and Windows Azure
Enable Classic Pipeline Mode Application Pool IIS and Windows Azure

Now after this change No other change will be required Everything is solved now . browse your website everything will be fine .

In case you face some Problem or Same Error Persist You may try the following solutions that can help in resolving issue 

 Changes in Web.Config File (Optional )


1. First open your Web.Config file and Search for <Configuration> Tag opening part and then insert following code in it and it should look like below --

<configuration>
    <system.webServer>
        <validation validateIntegratedModeConfiguration="false"/>
    </system.webServer>
</configuration>

Sunday 25 January 2015

Using Entity Framework Code First Migration Asp MVC

 Code First Database Initializers


 Before understanding code first migrations, let's have a look at Code First Database Initializers   provided by Entity Framework. When you follow EF code first approach, then you have three op tions for initializing database as given below–
  1. CreateDatabaseIfNotExists

    This is the default database initializer class used by Code First. This class creates a database only if it doesn't exist. This initializer helps you to avoid any accidental deletion of the database.
  2. DropCreateDatabaseWhenModelChanges

    This database initializer class drop the existing database and re-creates it if there is a mismatch between the model classes and table schema. This initializer is useful during starting phase of development and testing when models are changing often and there is no concern about the existing database records.
  3. DropCreateDatabaseAlways

    This database initializer class always drop and creates a new database, whether it is already present or not with every run of the application. This initializer is useful during testing when you want to run the application with a fresh set of data.

    Why Code First Migrations?

    The above three database initializing approach become fail when you add new model classes and you want to update existing database without any deletion or change. To achieve this, you need to use EF code first migrations which allow you to update existing database with new model classes changes and your existing database remains same with your database records.

    Visual Studio Package Manager Console

    To create the database for these two entities within your application, go to the Package Manager Console option as shown below:

    Creating New Database

    Running Commands

    Run the following command to configure migrations within your project and for creating new database.
  4. Enable migrations

    Enable-Migrations
  5. Create migration

    Add-Migration MigrationsName
  6. Create upgrade/downgrade script

    Update-Database

  7. Updating Existing Database

    Suppose you have added one more class named as Customer into your data model classes as given below:

    Running Commands

    Now for updating the database with new changes run the following commands as given below:
  8. Create migration

    Add-Migration MigrationsName
  9. Create upgrade/downgrade script

    Update-Database