As you can see today many of websites and web application need authentication for using that service. you can create your own such web service which authenticates and creates new user using any database language.But what happens sometimes by mistakes you may make some mistakes which may make a security flaw to your website. To avoid it you can use Membership schema provided by asp.net.so that errors to be made by you becomes zero.
So lets start.
1.Configuring Your Web Application. If you are using visual studio 2008 when you create new website web.config file is automatically created else create a new web.config file in your project. Now in Menubar go to ASP.NET configuration.select the security tab,select authentication type link.Then you will see two options. a)From Internet. b)From Local Network.
Select "From Internet" and press done. save all.
2.creating Webpages and coding.
The Authentication Code is like this
if (Membership.ValidateUser(Login1.UserName, Login1.Password)) { FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, Login1.UserName, DateTime.Now, DateTime.Now.AddMinutes(50), Login1.RememberMeSet, "demo"); string hashticket = FormsAuthentication.Encrypt(ticket);
HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, hashticket); Response.Cookies.Add(cookie);
string returnUrl = Request.QueryString["ReturnUrl"]; if (returnUrl == null) returnUrl = "~/Default.aspx";
Response.Redirect(returnUrl); }
Benifits of this method:Less Coding,More inbuilt Security Features.
AttachmentsAuthenticaiondemo (688-10031-Authenticationdemo.zip)
|
No feedbacks found. Be the first to respond and make money from revenue sharing program.
|