Wednesday, April 2, 2014
Tuesday, April 1, 2014
How to Correctly Detect Credit Card Type
| http://creditcardjs.com/credit-card-type-detection Card Type | Card Number Prefix |
|---|---|
| American Express | 34, 37 |
| China UnionPay | 62, 88 |
| Diners ClubCarte Blanche | 300-305 |
| Diners Club International | 300-305, 309, 36, 38-39 |
| Diners Club US & Canada | 54, 55 |
| Discover Card | 6011, 622126-622925, 644-649, 65 |
| JCB | 3528-3589 |
| Laser | 6304, 6706, 6771, 6709 |
| Maestro | 5018, 5020, 5038, 5612, 5893, 6304, 6759, 6761, 6762, 6763, 0604, 6390 |
| Dankort | 5019 |
| MasterCard | 50-55 |
| Visa | 4 |
| Visa Electron | 4026, 417500, 4405, 4508, 4844, 4913, 4917 |
Monday, March 31, 2014
The simple way to add Google login (OpenID) into ASP.NET MVC project
Step 1: Add DotnetOpenAuth lib from http://www.dotnetopenauth.net/ into ASP.NET MVC project reference
Step 2: Add following section into web.config file:
Step 3: Add an action for Authentication
Step 4: Add a link to point to this Action
@Html.ActionLink("Log in using Google", "LoginByGoogle")
Step 2: Add following section into web.config file:
Step 3: Add an action for Authentication
protected static OpenIdRelyingParty openid = new OpenIdRelyingParty();
[ValidateInput(false)]
public ActionResult LoginByGoogle(string returnUrl)
{
var response = openid.GetResponse();
if (response == null)
{
string openidUrl = "https://www.google.com/accounts/o8/id";
Identifier id;
if (Identifier.TryParse(openidUrl, out id))
{
try
{
var req = openid.CreateRequest(openidUrl);
var fetch = new FetchRequest();
fetch.Attributes.Add(new AttributeRequest(WellKnownAttributes.Contact.Email, true));
req.AddExtension(fetch);
return req.RedirectingResponse.AsActionResult();
}
catch (ProtocolException ex)
{
ViewData["Message"] = ex.Message;
return View("LogOn");
}
}
ViewData["Message"] = "Invalid identifier";
return View("LogOn");
}
switch (response.Status)
{
case AuthenticationStatus.Authenticated:
Session["FriendlyIdentifier"] = response.ClaimedIdentifier;
var sreg = response.GetExtension();
if (sreg != null)
{
var model = new RegisterModel()
{
Email = sreg.Email,
};
FormsAuthentication.SetAuthCookie(model.Email, true /* createPersistentCookie */);
return RedirectToAction("Home", "Index");
}
return View("LogOn");
case AuthenticationStatus.Canceled:
ViewData["Message"] = "Canceled at provider";
return View("LogOn");
case AuthenticationStatus.Failed:
ViewData["Message"] = response.Exception.Message;
return View("LogOn");
}
return new EmptyResult();
}
Step 4: Add a link to point to this Action
@Html.ActionLink("Log in using Google", "LoginByGoogle")
Subscribe to:
Posts (Atom)