<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-3140213949522728816</id><updated>2011-11-27T16:04:08.963-08:00</updated><title type='text'>ASP.NET</title><subtitle type='html'>Various topics in ASP.NET</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://sameer-aspnet.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3140213949522728816/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://sameer-aspnet.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Sameer</name><uri>http://www.blogger.com/profile/00036370584471142084</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>5</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3140213949522728816.post-5702656697838524987</id><published>2011-06-06T23:44:00.000-07:00</published><updated>2011-06-06T23:46:49.675-07:00</updated><title type='text'></title><content type='html'>&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable  {mso-style-name:"Table Normal";  mso-tstyle-rowband-size:0;  mso-tstyle-colband-size:0;  mso-style-noshow:yes;  mso-style-parent:"";  mso-padding-alt:0in 5.4pt 0in 5.4pt;  mso-para-margin:0in;  mso-para-margin-bottom:.0001pt;  mso-pagination:widow-orphan;  font-size:10.0pt;  font-family:"Times New Roman";} &lt;/style&gt; &lt;![endif]--&gt;to &lt;p class="MsoNormal"&gt; &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3140213949522728816-5702656697838524987?l=sameer-aspnet.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sameer-aspnet.blogspot.com/feeds/5702656697838524987/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3140213949522728816&amp;postID=5702656697838524987' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3140213949522728816/posts/default/5702656697838524987'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3140213949522728816/posts/default/5702656697838524987'/><link rel='alternate' type='text/html' href='http://sameer-aspnet.blogspot.com/2011/06/how-to-calculate-coverage.html' title=''/><author><name>Sameer</name><uri>http://www.blogger.com/profile/00036370584471142084</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3140213949522728816.post-3912771232600855667</id><published>2008-12-16T02:48:00.000-08:00</published><updated>2008-12-16T03:48:56.955-08:00</updated><title type='text'>Security in ASP.NET</title><content type='html'>&lt;div style="text-align: justify;"&gt;                   In every web based application, the main concern that should be taken care from the very beginning is security. Although we have https which is secure but all before that there is a need to have security checks at the time when user submits the information.&lt;br /&gt;                  Here I will not talk about the Forms Authentication as I consider the reader to be aware about it but its better to study it before going any further. You can learn about Forms Authentication in &lt;span style="font-size:85%;"&gt;&lt;cite&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;www.4guysfromrolla.com/webtech/110701-1.shtml. &lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;                        Let start with Membership &amp;amp; Role Manager. Basically it has two classes ie Membership &amp;amp; MembershipUser. Some common tasks performed by Membership class are as follows:-&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/cite&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt; Creating a new &lt;b&gt;MembershipUser&lt;/b&gt;   &lt;/li&gt;&lt;li&gt; Validating a username-password combination when a user attempts to log in   &lt;/li&gt;&lt;li&gt; Retrieving  &lt;b&gt;MembershipUser&lt;/b&gt; instance   &lt;/li&gt;&lt;li&gt; Updating  &lt;b&gt;MembershipUser&lt;/b&gt; instance    &lt;/li&gt;&lt;li&gt; Searching for users    &lt;/li&gt;&lt;li&gt; Getting the count of authenticated users that are currently online   &lt;/li&gt;&lt;li&gt; Deleting users from the system when they are no longer needed&lt;/li&gt;&lt;/ul&gt;          Now lets see what is Role Manager.   The Roles provides methods for creating roles and assigning users to roles. Some common tasks performed by roles are:-&lt;br /&gt;&lt;ul&gt;&lt;li&gt; Creating a new role   &lt;/li&gt;&lt;li&gt; Deleting an existing role   &lt;/li&gt;&lt;li&gt; Assigning users to roles   &lt;/li&gt;&lt;li&gt; Removing users from roles   &lt;/li&gt;&lt;li&gt; Determining if a user is authorized to a specific role   &lt;/li&gt;&lt;li&gt; Searching for users in a specific role, as well as retrieving all users in a role   &lt;/li&gt;&lt;li&gt; Getting the role information for a specific user &lt;/li&gt;&lt;/ul&gt;Following is a step by step code snippet  in implementing membership &amp;amp; assigning Roles:-&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Create User:  On button click write this code&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color:blue;"&gt;    string&lt;/span&gt; userName = txtUserId.Text;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:blue;"&gt;string&lt;/span&gt; password = txtPassword.Text;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:blue;"&gt;string&lt;/span&gt; email = txtEmail.Text;&lt;br /&gt;&lt;span style="color:blue;"&gt;string&lt;/span&gt; passwordQuestion = ddlPasswordQuestion.SelectedValue;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:blue;"&gt;string&lt;/span&gt; passwordAnswer = txtPasswordAnswer.Text;&lt;br /&gt;&lt;br /&gt;MembershipCreateStatus result;&lt;br /&gt;Membership.CreateUser(userName, password, email, passwordQuestion, passwordAnswer, &lt;span style="color:blue;"&gt;true&lt;/span&gt;,&lt;span style="color:blue;"&gt;out&lt;/span&gt; result);&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;&lt;pre&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size:130%;"&gt;User Login:&lt;/span&gt; &lt;/span&gt;&lt;br /&gt;On page Load write this code &lt;span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color:blue;"&gt; private&lt;/span&gt; MembershipUser memUser;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span style="font-size:100%;"&gt; memUser = Membership.GetUser();&lt;br /&gt;&lt;br /&gt;On Logout button write this code:&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span style="font-size:100%;"&gt;FormsAuthentication.SignOut();&lt;br /&gt;Roles.DeleteCookie();&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;&lt;pre&gt;&lt;span style="font-size:130%;"&gt;Manage Roles: On button click of create role write this,&lt;br /&gt;&lt;/span&gt;&lt;span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color:blue;"&gt;        string&lt;/span&gt; roleName = txtCreateRole.Text;&lt;br /&gt;&lt;br /&gt;   Roles.CreateRole(roleName);&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;&lt;pre&gt;&lt;span style="font-size:130%;"&gt;Manage User and Roles: Write this code on button click&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span&gt;&lt;span style="font-size:100%;"&gt;Roles.AddUserToRole(User.Identity.Name, selectedRole);&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;&lt;pre&gt;&lt;span style="font-size:130%;"&gt;Check Authorization:&lt;/span&gt; Write this code on page load&lt;br /&gt;if(User.IsInRole("Administrator")&lt;br /&gt;{&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;Response.Write("Invalid User");&lt;br /&gt;}&lt;/pre&gt;&lt;/li&gt;&lt;/ol&gt;This is just an overview how Membership and Roles can be managed for security in ASP.NET&lt;br /&gt;For complete code with working example, you can contact me at sameersayani@gmail.com&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;cite&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;                           &lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;/span&gt;&lt;/span&gt; &lt;/cite&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3140213949522728816-3912771232600855667?l=sameer-aspnet.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sameer-aspnet.blogspot.com/feeds/3912771232600855667/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3140213949522728816&amp;postID=3912771232600855667' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3140213949522728816/posts/default/3912771232600855667'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3140213949522728816/posts/default/3912771232600855667'/><link rel='alternate' type='text/html' href='http://sameer-aspnet.blogspot.com/2008/12/security-in-aspnet.html' title='Security in ASP.NET'/><author><name>Sameer</name><uri>http://www.blogger.com/profile/00036370584471142084</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3140213949522728816.post-5330568625968298496</id><published>2007-10-30T06:40:00.000-07:00</published><updated>2007-10-30T06:40:36.437-07:00</updated><title type='text'>Quick Help ASP.NET: Generating Random nos. without any Duplication</title><content type='html'>&lt;a href="http://sameer-aspnet.blogspot.com/2007/10/generating-random-nos-without-any.html"&gt;Quick Help ASP.NET: Generating Random nos. without any Duplication&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3140213949522728816-5330568625968298496?l=sameer-aspnet.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='related' href='http://sameer-aspnet.blogspot.com/2007/10/generating-random-nos-without-any.html' title='Quick Help ASP.NET: Generating Random nos. without any Duplication'/><link rel='replies' type='application/atom+xml' href='http://sameer-aspnet.blogspot.com/feeds/5330568625968298496/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3140213949522728816&amp;postID=5330568625968298496' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3140213949522728816/posts/default/5330568625968298496'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3140213949522728816/posts/default/5330568625968298496'/><link rel='alternate' type='text/html' href='http://sameer-aspnet.blogspot.com/2007/10/quick-help-aspnet-generating-random-nos.html' title='Quick Help ASP.NET: Generating Random nos. without any Duplication'/><author><name>Sameer</name><uri>http://www.blogger.com/profile/00036370584471142084</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3140213949522728816.post-7152128222152861830</id><published>2007-10-24T07:01:00.000-07:00</published><updated>2007-10-24T07:23:31.575-07:00</updated><title type='text'>Generating Random nos. without any Duplication</title><content type='html'>We often came across situations like generating Random nos. during coding.Suppose if any user gets regitered to our site, we may provide him System generated password or we assign him with a unique key for identification.This can be done in many nos of ways in ASP.NET. we can use GUID() in ASP.NET.GUID Return a Globally Unique Identifier (GUID).But after a certain limit, it will start generating duplicate combination of nos.&lt;br /&gt;    The other way round is to make our own unique key ie like generating a key with acombination of user email ID.But what if the special character ike @ is not allowed?&lt;br /&gt;      In the following program, i am generating my own unique Alpha numeric key which is always unique.Here's the code:-&lt;br /&gt;        &lt;br /&gt;&lt;br /&gt;using System.Security.Cryptography;&lt;br /&gt;&lt;br /&gt;public static void main()&lt;br /&gt;{&lt;br /&gt;   string str= GetUniqueKey();&lt;br /&gt;   Console.Write(str);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;private string GetUniqueKey()&lt;br /&gt;{&lt;br /&gt;int maxSize = 8;&lt;br /&gt;int minSize = 5;&lt;br /&gt;char[] chars = new char[62];&lt;br /&gt;string a;&lt;br /&gt;string main = "";&lt;br /&gt;a = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";&lt;br /&gt;chars = a.ToCharArray();&lt;br /&gt;int size = maxSize;&lt;br /&gt;byte[] data = new byte[1];&lt;br /&gt;RNGCryptoServiceProvider crypto = new RNGCryptoServiceProvider();&lt;br /&gt;crypto.GetNonZeroBytes(data);&lt;br /&gt;size = maxSize;&lt;br /&gt;data = new byte[size];&lt;br /&gt;crypto.GetNonZeroBytes(data);&lt;br /&gt;StringBuilder result = new StringBuilder(size);&lt;br /&gt;foreach (byte b in data)&lt;br /&gt;{&lt;br /&gt;result.Append(chars[b % (chars.Length - 1)]);&lt;br /&gt;}&lt;br /&gt;return result.ToString();&lt;br /&gt;}   &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;You can modify it to produce only numeric nos.It can be modified in any ways.But for this we have to import cryptography class for that.Cryptography provides different methods for Encryption,Decryption.&lt;br /&gt;&lt;br /&gt;Use it &amp;amp; give me your feed back.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3140213949522728816-7152128222152861830?l=sameer-aspnet.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sameer-aspnet.blogspot.com/feeds/7152128222152861830/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3140213949522728816&amp;postID=7152128222152861830' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3140213949522728816/posts/default/7152128222152861830'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3140213949522728816/posts/default/7152128222152861830'/><link rel='alternate' type='text/html' href='http://sameer-aspnet.blogspot.com/2007/10/generating-random-nos-without-any.html' title='Generating Random nos. without any Duplication'/><author><name>Sameer</name><uri>http://www.blogger.com/profile/00036370584471142084</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3140213949522728816.post-3944281878172587670</id><published>2007-10-17T05:00:00.000-07:00</published><updated>2007-10-17T05:16:06.632-07:00</updated><title type='text'>PostBack in ASP.NET</title><content type='html'>Lets consider a .aspx page in ASP.NET which consists of a some fields having a Submit button at its end.When we click on submit button,the page is submitted back to server for processing along with data on page.Finally our data gets saved in the database.This is due to the PostBack property.This property runs our code on server side to fulfill the task.Similarly suppose if we have dropdownlist which are bound to database can be viewed on Page Load.But there is no need to fill the dropdown once it is filled.For that ASP.NET provides us a functionality to check whether the Page.IsPostBack property is true or false.It is true for the first time page on load but in all other operations on the same page it is false.So it will not fill th dropdown again &amp;amp; again  and save our time as it will not connect to the database again.&lt;br /&gt;        This property was not present in Classic ASP.Hence the code was executed line by line from top to bottom.To avoid this we use iframes in that which was more tedious job.&lt;br /&gt;         This is what Postback in ASP.NET means&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3140213949522728816-3944281878172587670?l=sameer-aspnet.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sameer-aspnet.blogspot.com/feeds/3944281878172587670/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3140213949522728816&amp;postID=3944281878172587670' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3140213949522728816/posts/default/3944281878172587670'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3140213949522728816/posts/default/3944281878172587670'/><link rel='alternate' type='text/html' href='http://sameer-aspnet.blogspot.com/2007/10/postback-in-aspnet.html' title='PostBack in ASP.NET'/><author><name>Sameer</name><uri>http://www.blogger.com/profile/00036370584471142084</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
