Bulan-bulan ini sebenarnya saya sering ngeblog di ruang sebelah. Ngeblog di DEV itu sebenarnya berarti ada ‘masalah’ , uhuii..! Dokumentasi troubleshoot dan problem solving biasanya saya tuliskan diblog. Kebanyakan menggunakan bahasa C#, SQL, MDX dan sedikit ABAP, doh! ini resiko kerja di multiplatform! Dan baru saja saya sadari, eh.. mungkin juga menjadi pertanyaan beberapa kalangan… Continue reading
Posts tagged "c#"
Get UserName on ASP.NET Membership Provider
If you are using ASP.NET Membership Provider for a website, one simple and practical way how to get ‘username’ for logging activities on CRUD (Create Read Update Delete) implementation is by storing the “username” on a session. Put this little code on Default page, or first landing page after succesfull user login.
1 |
using System.Web.Security; |
…
1 2 3 4 5 6 7 8 9 |
protected void Page_Load(object sender, EventArgs e) { //check user login if (User.Identity.IsAuthenticated) { //get username and put into session Session["UserName"] = Membership.GetUser().UserName.ToString(); } } |
Encrypt and Decrypt Web.Config (Connection Strings, etc) from ASP Page
Example: How to encrypt/decrypt connectionStrings and SessionState section on Web.Config file? This is a codebehid sample script written on C# to perform Encrypt and Decrypt procedure against few items on Web.Config file. Single ASP.NET page can perform this task easily, so you don’t have to write any code in command prompt. Declare this namespace:
1 2 3 |
using System.Web; using System.Web.Configuration; using System.Web.Security; |