現在、いくつかのレガシー コードに取り組んでおり、Global.asax ファイルを親アプリケーションに移動しようとしています。これにより、すべての子アプリケーションが管理されます。現在、すべての子アプリに Global.asax ファイルがあります (悪い)。
子アプリケーションから Global.asax ファイルを削除しようとすると、残念ながら親アプリケーションの Global.asax ファイルが見つかりません。したがって、子アプリ内で認証されたままにすることはできません。これに対する簡単な修正があるかどうか疑問に思っていました。
構造:
parent app
files...
childapp
files..
global.asax
global.asax
childapp が親の Global.asax ファイルを見つけられるようにします。
みんなありがとう!
編集:
Global.asax
(これは親アプリと子アプリで同じです)
protected void Application_Start(object sender, EventArgs e)
{
}
protected void Session_Start(object sender, EventArgs e)
{
}
protected void Application_BeginRequest(object sender, EventArgs e)
{
}
public void Application_AuthenticateRequest(Object sender, EventArgs e)
{
String cookieName = FormsAuthentication.FormsCookieName;
HttpCookie authCookie = Context.Request.Cookies[cookieName];
if (null == authCookie)
{//There is no authentication cookie.
return;
}
FormsAuthenticationTicket authTicket = null;
try
{
authTicket = FormsAuthentication.Decrypt(authCookie.Value);
}
catch (Exception ex)
{
//Write the exception to the Event Log.
return;
}
if (null == authTicket)
{//Cookie failed to decrypt.
return;
}
//When the ticket was created, the UserData property was assigned a
//pipe-delimited string of group names.
String[] groups = authTicket.UserData.Split(new char[] { '|' });
//Create an Identity.
GenericIdentity id = new GenericIdentity(authTicket.Name, "LdapAuthentication");
//This principal flows throughout the request.
GenericPrincipal principal = new GenericPrincipal(id, groups);
Context.User = principal;
}
protected void Application_Error(object sender, EventArgs e)
{
}
protected void Session_End(object sender, EventArgs e)
{
}
protected void Application_End(object sender, EventArgs e)
{
}