Use constructor with connection string
http://msdn.microsoft.com/en-us/library/bb739017.aspx
var db = new dbContext(connectionString);
Thursday, December 20, 2012
How to change ASP.NET membership database connection string dynamically?
By reflection:
private void SetProviderConnectionString(string connectionString) { // Set private property of Membership, Role and Profile providers. FieldInfo connectionStringField = Membership.Provider.GetType().GetField("_sqlConnectionString", BindingFlags.Instance | BindingFlags.NonPublic); if (connectionStringField != null) connectionStringField.SetValue(Membership.Provider, connectionString); FieldInfo roleField = Roles.Provider.GetType().GetField("_sqlConnectionString", BindingFlags.Instance | BindingFlags.NonPublic); if (roleField != null) roleField.SetValue(Roles.Provider, connectionString); FieldInfo profileField = ProfileManager.Provider.GetType().GetField("_sqlConnectionString", BindingFlags.Instance | BindingFlags.NonPublic); if (profileField != null) profileField.SetValue(ProfileManager.Provider, connectionString); }
How to call WCF service in ASP.NET ?
Add following setting in web.config:
http://msdn.microsoft.com/en-ca/library/bb763177(v=vs.90).aspx
How to solve "CustomError for 403 Forbidden not working"?
In IIS 7 add following settings into web.config
How to use QR code in ASP.NET MVC?
The lib is: QRCODENET
http://qrcodenet.codeplex.com/
http://qrcodenet.codeplex.com/
public ActionResult QRImage(int id) { string url = string.Format("http://myevents.apphb.com/event/details/{0}", id); QrEncoder qrEncoder = new QrEncoder(ErrorCorrectionLevel.H); QrCode qrCode = qrEncoder.Encode(url); GraphicsRenderer renderer = new GraphicsRenderer(new FixedModuleSize(5, QuietZoneModules.Two), Brushes.Black, Brushes.White); MemoryStream ms = new MemoryStream(); renderer.WriteToStream(qrCode.Matrix, ImageFormat.Png, ms); byte[] image = ms.ToArray(); ; return File(image, "image/png"); }
Subscribe to:
Posts (Atom)