| 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 |
Tuesday, April 1, 2014
How to Correctly Detect Credit Card Type
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")
Tuesday, March 25, 2014
How to add log4net into ASP.NET project?
1. Download dll file from
http://logging.apache.org/log4net/download_log4net.cgi
2.Add following log4net.config file into project
4. Add write permission setting for log file folder
IIS manager -> Application pool -> Get name of application pool
File explorer -> folder property -> Security -> Add IIS AppPool\\app pool name into log file folder write/read permission.
http://blogs.iis.net/webdevelopertips/archive/2009/10/02/tip-98-did-you-know-the-default-application-pool-identity-in-iis-7
-5-windows-7-changed-from-networkservice-to-apppoolidentity.aspx
5. Usage:
References:
Apache log4net™ Manual - Configuration
http://logging.apache.org/log4net/release/manual/configuration.html
http://ruchirac.blogspot.ca/2012/10/configure-log4net-with-aspnet-logging.html
http://logging.apache.org/log4net/download_log4net.cgi
2.Add following log4net.config file into project
3. In Global.asax
protected void Application_Start()
{
string l4net = Server.MapPath("~/log4net.config");
log4net.Config.XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo(l4net));
}
4. Add write permission setting for log file folder
IIS manager -> Application pool -> Get name of application pool
File explorer -> folder property -> Security -> Add IIS AppPool\\app pool name into log file folder write/read permission.
http://blogs.iis.net/webdevelopertips/archive/2009/10/02/tip-98-did-you-know-the-default-application-pool-identity-in-iis-7
-5-windows-7-changed-from-networkservice-to-apppoolidentity.aspx
5. Usage:
ILog log = LogManager.GetLogger(typeof(this));
log.Info("message");
References:
Apache log4net™ Manual - Configuration
http://logging.apache.org/log4net/release/manual/configuration.html
http://ruchirac.blogspot.ca/2012/10/configure-log4net-with-aspnet-logging.html
Monday, March 24, 2014
How to get application root path in ASP.MVC 3 and 3+
string rootpath = HttpContext.Current.Request.ApplicationPath;
Or
string rootpath = Url.Content("~"),
Or
string rootpath = Url.Content("~"),
Subscribe to:
Posts (Atom)