Thursday, May 21, 2015

Get Ionic framework working behind proxy

I have the error to create a new ionic project when running the command in windows 7
ionic start myproject

The solution is to set up the MAGIC environment variable in the computer settings, then it works.
http_proxy=http://username:password@hostname:port;

Wednesday, May 6, 2015

Error to download bower package in Visual studio 2015 RC when you are in corporate proxy

1. add a .bowerrc file in project,
{
"proxy": "http://192.168.11.22:8080",
"https-proxy":"http://192.168.11.22:8080"
}

2. Install Git seperately

3. go to command prompt and run the following cmd
git config --global http.proxy http://proxyuser:proxypwd@proxy.server.com:8080
git config --global https.proxy https://proxyuser:proxypwd@proxy.server.com:8080

Tuesday, May 5, 2015

Error to download npm package in Visual studio 2015 when you are in corporate proxy

This is the command to run to set up the proxy,

npm config set proxy http://proxy.company.com:8080
npm config set https-proxy http://proxy.company.com:8080

But where to run this command, the npm.cmd is in,
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\External

Open a command prompt as administrator and run the npm config ...
Then it worked.

Custom asp.net identity 2.1 tables and primary keys

This is the codes that I use to set up the identity tables to use int as primary key.

public class User : IdentityUser<int, UserLogin, UserRole, UserClaim>



{
 
public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<User, int> manager)



{
 
// Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType

var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);

// Add custom user claims here

return userIdentity;



}
 
public string FirstName { get; set; }

public string LastName { get; set; }

public byte Level { get; set; }

public DateTime JoinDate { get; set; }




}
 
public class UserRole : IdentityUserRole<int> { }

public class UserLogin : IdentityUserLogin<int> { }

public class UserClaim : IdentityUserClaim<int> { }

public class Role : IdentityRole<int, UserRole>



{
 
public Role() { }

public Role(string name) { Name = name; }



}
 
public class MyUserStore : UserStore<User, Role, int, UserLogin, UserRole, UserClaim>



{
 
public MyUserStore(MyPortalContext context)

: base(context) { }



}
 
public class MyRoleStore : RoleStore<Role, int, UserRole>



{
 
public MyRoleStore(MyPortalContext context)

: base(context) { }



}

/////////////////////////////////////////////////////////

And they are customized to use different table names in MyPortalContext

protected override void OnModelCreating(DbModelBuilder modelBuilder)



{
 
base.OnModelCreating(modelBuilder);

modelBuilder.Entity<User>().ToTable("Users");

modelBuilder.Entity<Role>().ToTable("Roles");

modelBuilder.Entity<UserLogin>().ToTable("UserLogins");

modelBuilder.Entity<UserClaim>().ToTable("UserClaims");

modelBuilder.Entity<UserRole>().ToTable("UserRoles");
}