Ask a Question related to ASP.NET Security, Design and Development.
-
William Gower #1
Using forms authentication for the first time
I have set up my web config file to use Forms Authentication. In my login
page after I validate my user, I want to store the id but I don't want to
call the RedirectFromLoginPage. I want to redirect the page myself. How do
I store the id without calling RedirectFromLoginPage?
William Gower Guest
-
Accessing htm files without authentication (forms authentication)
I have application with forms authentication. All works fine. When user opens .aspx file gets login form, login and then get the .aspx page. But... -
ASP.Net Forms authentication with basic authentication popup
Relatively new to ASP.Net but have a strange problem. My site uses forms authentication for a large administration section however after the user... -
Forms authentication then redirection to a secure web with NT authentication?
Hi, I want to allow access to particular secured intranet web sites. These intranet are stored in sharepoint (2003 version) Actually I've... -
Authentication ticket, cookieless, forms authentication?
Hi. I want to use Forms Authentication, cookieless. The issue is setting the Authentication Ticket without using cookies (!) That is, the... -
Forms authentication with Windows authentication
Hi, I have an ASP.NET web site that uses IIS Basic Authentication and accesses an OLAP Server at various stages. The OLAP Server authentication... -
Raterus #2
Re: Using forms authentication for the first time
If you don't need to redirect, you can use "SetAuthCookie" to achieve the same effect.
[url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemWebSecurityFormsAuthenticationClassSetA uthCookieTopic2.asp[/url]
"William Gower" <w_gower@hotmail.com> wrote in message news:%233We1zLeEHA.3664@TK2MSFTNGP12.phx.gbl...> I have set up my web config file to use Forms Authentication. In my login
> page after I validate my user, I want to store the id but I don't want to
> call the RedirectFromLoginPage. I want to redirect the page myself. How do
> I store the id without calling RedirectFromLoginPage?
>
>Raterus Guest
-
Hernan de Lahitte #3
Re: Using forms authentication for the first time
You should create the ticket by your self. Here is a sample code:
Place this code instead of "FormsAuthentication.RedirectFromLoginPage(
UserId.Text, false )"
HttpCookie cookie = FormsAuthentication.GetAuthCookie( UserId.Text, false );
FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(
cookie.Value );
// Store roles inside the Forms cookie.
FormsAuthenticationTicket newticket = new FormsAuthenticationTicket(
ticket.Version,
ticket.Name,
ticket.IssueDate,
ticket.Expiration,
ticket.IsPersistent,
userData,
ticket.CookiePath );
cookie.Value = FormsAuthentication.Encrypt(newticket);
Response.Cookies.Set(cookie);
Response.Redirect( FormsAuthentication.GetRedirectUrl( newticket.Name,
newticket.IsPersistent ) );
In case you don't have any userData (some string data up to 1200 bytes
aprox) to store inside the ticket, you might use this
FormsAuthenticationTicket overload:
FormsAuthenticationTicket newticket2 = new FormsAuthenticationTicket(
ticket.Name, ticket.IsPersistent, ticket.Expiration.Subtract(
ticket.IssueDate ).Minutes );
Hope this help.
--
Hernan de Lahitte
Lagash Systems S.A.
[url]http://weblogs.asp.net/hernandl[/url]
This posting is provided "AS IS" with no warranties, and confers no rights.
"William Gower" <w_gower@hotmail.com> wrote in message
news:%233We1zLeEHA.3664@TK2MSFTNGP12.phx.gbl...do> I have set up my web config file to use Forms Authentication. In my login
> page after I validate my user, I want to store the id but I don't want to
> call the RedirectFromLoginPage. I want to redirect the page myself. How> I store the id without calling RedirectFromLoginPage?
>
>
Hernan de Lahitte Guest
-
Hernan de Lahitte #4
Re: Using forms authentication for the first time
Agreed with Raterus.
Something like:
FormsAuthentication.SetAuthCookie( UserId.Text, false );
Response.Redirect( "yourPage.aspx" );
should be ok.
--
Hernan de Lahitte
Lagash Systems S.A.
[url]http://weblogs.asp.net/hernandl[/url]
This posting is provided "AS IS" with no warranties, and confers no rights.
"Hernan de Lahitte" <hernan@lagash.com> wrote in message
news:OSqRurNeEHA.384@TK2MSFTNGP10.phx.gbl...false );> You should create the ticket by your self. Here is a sample code:
>
> Place this code instead of "FormsAuthentication.RedirectFromLoginPage(
> UserId.Text, false )"
>
> HttpCookie cookie = FormsAuthentication.GetAuthCookie( UserId.Text,rights.> FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(
> cookie.Value );
> // Store roles inside the Forms cookie.
> FormsAuthenticationTicket newticket = new FormsAuthenticationTicket(
> ticket.Version,
>
> ticket.Name,
>
> ticket.IssueDate,
>
> ticket.Expiration,
>
> ticket.IsPersistent,
>
> userData,
>
> ticket.CookiePath );
> cookie.Value = FormsAuthentication.Encrypt(newticket);
> Response.Cookies.Set(cookie);
> Response.Redirect( FormsAuthentication.GetRedirectUrl( newticket.Name,
> newticket.IsPersistent ) );
>
> In case you don't have any userData (some string data up to 1200 bytes
> aprox) to store inside the ticket, you might use this
> FormsAuthenticationTicket overload:
>
> FormsAuthenticationTicket newticket2 = new FormsAuthenticationTicket(
> ticket.Name, ticket.IsPersistent, ticket.Expiration.Subtract(
> ticket.IssueDate ).Minutes );
>
>
> Hope this help.
>
> --
> Hernan de Lahitte
> Lagash Systems S.A.
> [url]http://weblogs.asp.net/hernandl[/url]
>
>
> This posting is provided "AS IS" with no warranties, and confers nologin>
> "William Gower" <w_gower@hotmail.com> wrote in message
> news:%233We1zLeEHA.3664@TK2MSFTNGP12.phx.gbl...> > I have set up my web config file to use Forms Authentication. In myto> > page after I validate my user, I want to store the id but I don't wantHow> > call the RedirectFromLoginPage. I want to redirect the page myself.> do>> > I store the id without calling RedirectFromLoginPage?
> >
> >
>
Hernan de Lahitte Guest



Reply With Quote

