Help Please: Two WebProjects -- One Forms Authentication

From: Damen (dm.development@netcabo.pt)
Date: 11/29/02


From: "Damen" <dm.development@netcabo.pt>
Date: Fri, 29 Nov 2002 11:25:15 -0000


Hello,

Does anyone knows how can i have to WebProjects in C#.Net, and use the same
security for both.

I don't want that every time i hit a link that link's to the other project,
i get redirected to the login form.

I use forms authentication, my web.config files are equals in the two
projects (WebUI and WebCommon Projects).

WEBUI PROJECT - Web.Config
<forms name="AuthCookie" loginUrl="../WebUI/Login.aspx"
protection="All"></forms>

/*..............................

...................................*/

<!-- Valid directories for source browsing. Keep these lower case. -->

<add key="." value=" " />

<add key="..\segmodules" value=" " />

<add key="..\..\webcommon\commodules" value=" " />

<add key="..\css" value=" " />

WEBCOMMON PROJECT - Web.Config

<forms name="AuthCookie" loginUrl="../WebUI/Login.aspx"
protection="All"></forms>

/*..............................

...................................*/

<!-- Valid directories for source browsing. Keep these lower case. -->

<add key="." value=" " />

<add key="..\..\webui\segmodules" value=" " />

<add key="..\commodul
s" value=" " />

<add key="..\css" value=" " />

GLOBAL.ASAX - IS EQUAL ON THE TWO PROJECTS:

protected void Application_AuthenticateRequest(Object sender, EventArgs e)

{

string cookieName = FormsAuthentication.FormsCookieName;

HttpCookie authCookie = Context.Request.Cookies[cookieName];

if ( null == authCookie)

{

return;

}

FormsAuthenticationTicket authTicket = null;

try

{

authTicket = FormsAuthentication.Decrypt(authCookie.Value);

}

catch (Exception ex)

{

Exception tst = ex;

return;

}

if ( null == authTicket )

{

return;

}

//Extrai os roles introduzidos no ticket, para os colocar num array de
strings

string[] roles = authTicket.UserData.Split('|');

//Cria um objecto Identity

FormsIdentity id = new FormsIdentity( authTicket );

// This principal will flow throughout the request.

//Este principal, vai funcionar ao longo da aplicação

CustomPrincipal principal = new CustomPrincipal(id, roles);

// Attach the new principal object to the current HttpContext object

Context.User = principal;

}

Can anyone help me???

Please help, thank you in advance,

Ricardo.

begin 666 sackville bagguins.vcf
M0D5'24XZ5D-!4D0-"E9%4E-)3TXZ,BXQ#0I..D)A<F)O<V$[1G)E9&5R:6-O
M#0I&3CIS86-K=FEL;&4@8F%G9W5I;G,-"DY)0TM.04U%.G-A8VMV:6QL92!B
M86=G=6EN<PT*6"U704(M1T5.1$52.C(-"D)$05DZ,3DW.#$R,3 -"D5-04E,
M.U!2148[24Y415).150Z9G)E9&5R:6-O8F%R8F]S84!I;VPN<'0-"E)%5CHR
<,# R,3$R.50Q,3(U,35:#0I%3D0Z5D-!4D0-"@``
`
end