Thursday, April 3, 2014

Move classic EC2 instance into VPC

  1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.
  2. Click Instances in the navigation pane.
  3. On the Instances page, right-click your running instance and select Create Image.
  4. Fill in a unique image name and an optional description of the image (up to 255 characters), and click Create Image.
  5. Go to the AMIs page and view the AMI's status. While the new AMI is being created, its status is pending.
  6. It takes a few minutes for the whole process to finish.
  7. Once your new AMI's status is available, go to the Snapshots page and view the new snapshot that was created for the new AMI. Any instance you launch from the new AMI uses this snapshot for its root device volume. You could update your Auto Scaling group with the new AMI, however we will do this as part of the AWS CloudFormation step.

Important information:
  1. We have to wait 30 mins after Lauch, for Password configuration.
  2. The password is the same as for the instance from which you created the AMI, unless this setting was modified in the EC2Config service settings.
  3. You will not use Same IP Address, becuase this IP address is allocated to classic EC2 pool and new instance will require an IP of VPC pool.
  4. After migration we will get all the informations same as it was in previous instance.
why migration required?
  1. classic EC2 not supported Multiple IPs
  2. classic Ec2 in not secured as VPC EC2, as classic Ec2 instance is touch with direct environment.

 

Tuesday, April 1, 2014

MVC - The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.

If you're running IIS 6 and above, make sure the application pool your MVC app. is using is set to Integrated Managed Pipeline Mode. I had mine set to Classic by mistake and the same error occurred.

What is difference between constants and read-only?


Constant and ReadOnly keyword are used to make a field constant which value cannot be modified.

Constant
Constant fields or local variables must be assigned a value at the time of declaration and after that they cannot be modified. By default constant are static, hence you cannot define a constant type as static.
public const int X = 10;
A const field is a compile-time constant. A constant field or local variable can be initialized with a constant expression which must be fully evaluated at compile time.
void Calculate(int Z)
{
  const int X = 10, X1 = 50;
  const int Y = X + X1; //no error, since its evaluated a compile time
  const int Y1 = X + Z; //gives error, since its evaluated at run time
}
You can apply const keyword to built-in value types (byte, short, int, long, char, float, double, decimal, bool), enum, a string literal, or a reference type which can be assigned with a value null.
const MyClass obj1 = null;//no error, since its evaluated a compile time
const MyClass obj2 = new MyClass();//gives error, since its evaluated at run time
Constants can be marked as public, private, protected, internal, or protected internal access modifiers.
Use the const modifier when you sure that the value a field or local variable would not be changed.

ReadOnly
A readonly field can be initialized either at the time of declaration or with in the constructor of same class. Therefore, readonly fields can be used for run-time constants.
class MyClass {
  readonly int X = 10; // initialized at the time of declaration
  readonly int X1;

  public MyClass(int x1)
  {
    X1 = x1; // initialized at run time
  }
}
Explicitly, you can specify a readonly field as static since, like constant by default it is not static. Readonly keyword can be apply to value type and reference type (which initialized by using the new keyword) both. Also, delegate and event could not be readonly.
Use the readonly modifier when you want to make a field constant at run time.