Tuesday, October 1, 2013

How do disable an account with the ASP.NET Membership Provider?

ASP.NET MEMBERSHIP USER LOCK BY C#

Islocked Method is read only property of membership user.
so we have to use alternatively method. it is same as isLocked method.
From below code we can lock the user from login. Once account has approved or 
unlock after that user will log in .

MembershipUser Lockeduser = Membership.GetUser(newUserAccount.UserID.Value);
if (Lockeduser != null)
{
 //disable online account
 Lockeduser.IsApproved = false;
 Membership.UpdateUser(Lockeduser);                        
}
 
please do not hesitate to comment .

Thanks
Vik Shah 
http://dakvikas.webs.com
 

Friday, September 20, 2013

How to force a page to use SSL (HTTPS) in ASP.NET (VB.NET/C#)

Force a page to use HTTPS instead of HTTP

The following sample code will force a page to use ssl woth asp.net . Please  add code in to Page_Load event

C#  Code

//this is the current url 
System.Uri currentUrl = System.Web.HttpContext.Current.Request.Url; 
//don't redirect if this is localhost 
 if (!currentUrl.IsLoopback)
 { 
  if (!currentUrl.Scheme.Equals(Uri.UriSchemeHttps, StringComparison.CurrentCultureIgnoreCase))
  { 
    //build the secure uri 
    System.UriBuilder secureUrlBuilder = new UriBuilder(currentUrl); 
    secureUrlBuilder.Scheme = Uri.UriSchemeHttps; 
    //use the default port. 
    secureUrlBuilder.Port = -1; 
    //redirect and end the response. 
    System.Web.HttpContext.Current.Response.Redirect(secureUrlBuilder.Uri.ToString()); 
   } 
  } 

VB.NET Code

'this is the current url 
Dim currentUrl As System.Uri = System.Web.HttpContext.Current.Request.Url
'don't redirect if this is localhost
If Not currentUrl.IsLoopback Then
 If Not currentUrl.Scheme.Equals(Uri.UriSchemeHttps, StringComparison.CurrentCultureIgnoreCase) Then
  'build the secure uri
  Dim secureUrlBuilder As System.UriBuilder = New UriBuilder(currentUrl)
  secureUrlBuilder.Scheme = Uri.UriSchemeHttps
  'use the default port. 
  secureUrlBuilder.Port = -1
  'redirect and end the response.
  System.Web.HttpContext.Current.Response.Redirect(secureUrlBuilder.Uri.ToString())
 End If
End If

Tuesday, September 17, 2013

Forcefully Rename a SQL Server Database






When SQL Server management studio give below error we have forcefully rename  for our database.


Management Studio is telling you that there are connections that it doesn’t want to mess with.
Or when using sp_renamedb from a query window, you might see this similar error:
Msg 5030, Level 16, State 2, Line 1
The database could not be exclusively locked to perform the operation.
If you really really want to rename the database and don’t care at all about in-flight transactions, then use this script/template I recently came up with:
A Forceful rename  Script:

ALTER DATABASE [old_name]
 
 SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO
ALTER DATABASE [old_name]
 
 MODIFY NAME = [new_name]
GO
ALTER DATABASE [new_name]
 SET MULTI_USER
GO
 
 
 

Monday, July 15, 2013

[SOLVED] "Attaching the Script debugger to process iexplore.exe failed" message after upgrading to Internet Explorer 10

HUGE thanks going out to Dmitri Leonov - MSFT in a stackoverflow article about the same message.
After updating to Internet Explorer 10, I started receiving the error when debugging with Visual Studio 2010:

"Attaching the Script debugger to process [####] iexplore.exe failed.  Another debugger may already be attached to the process."

The fix:

  • Close all instances of Internet Explorer.  (I will add you can leave Visual Studio open)
  • Run a command prompt as Administrator and paste this little gem into the command line:
 regsvr32.exe "%ProgramFiles(x86)%\Common Files\Microsoft Shared\VS7Debug\msdbg2.dll"
 
It worked like a champ for me (and apparently others from comments on the stackoverflow post.)

Reference links :
  1. http://stackoverflow.com/questions/13421797/vs2010-and-ie10-attaching-the-script-debugger-to-process-iexplore-exe-failed 
  2.  http://development.thatoneplace.net/2013/04/solved-attaching-script-debugger-to.html
  3. http://social.msdn.microsoft.com/Forums/vstudio/en-US/bbf26b82-5d00-4472-9bc4-be77a1fc8e9e/attaching-the-script-debugger-to-process-iexploreexe-on-machine-failed-a-debugger-is-already
 

Wednesday, July 10, 2013

Differentiate: Response.Redirect() and Server.Transfer() (via http://code4project.com)
Differentiate: Response.Redirect() and Server.Transfer() In ASP.Net “Server” and “Response” both are objects. 1.Server.Transfer 2.Response.Redirect Server.Transfer and Response.Redirect both are used to transfer one page to another. But there…

Tuesday, April 30, 2013

How To Create a Basic WordPress Theme

How To Create a Basic WordPress Theme (via www.techknowlogists.com)
If you are developer than the arsenal of your skills is not completed if it does not have the weapon of wordpress development. WordPress is a powerful CMS which can not only be used as a blogging platform but can also be extended to an e-commerce or rich social network. You can customize and override…

Monday, April 22, 2013

Anonymous authentication and asp.net impersonation

Anonymous authentication and asp.net impersonation Part 86 (via http://leaksfree.com)
Please watch Part 85, before watching this video. In Part 85, we discussed that IIS provides anonymous access to resources using IUSR account. Once the request is handed over to asp.net, the application code is executed using the application pool identity. In this video, we will discuss the effects…

Finding and Fixing Ajax’s Elusive Bugs

Finding and Fixing Ajax’s Elusive Bugs (via Dice News in Tech)
Let’s start with some background. Google was an early pioneer of the Web development technique called “Ajax.” Ironically, when you Google the phrase “What is Ajax?” the search engine comes back with A Greek hero of the Trojan war, son of Telamon, king of Salamis. He was proverbial for his…

live IPL Streaming links HD