I am looking at a C# asp.net web forms 2010 application to see how to add some new webpages to the main selection page uers see. (I have C#.net desktop experience, but I do not have C#. asp.net expereince).
Right now I am looking at code that works when a user selects a web page that is working versus a web page that is not working.
The application is looking for a file in the
http://localhost/path/app.aspx. However I do know know where this logic is that looks for the file listed above. is there another web.config and/or machine/config file i need to look for that. What file would i be looking for?
the code in Application_AuthenticateRequest seems to work ok. Then the next thing that happens is
Application_Error is called from ASP.global_asx as object sender and the eventsArgs e is empty.
I do not know how the Application_Error is even called.
When the error occurs, the following scenarios happens:
The global.asax.cs has the following code:
protected void Application_Error(object sender, EventArgs e)
{
Exception objErr = Server.GetLastError().GetBaseException();
string err = "Error Caught in Application_Error event\n" +
"Error in: " + Request.Url.ToString() +
"\nError Message:" + objErr.Message.ToString() +
"\nStack Trace:" + objErr.StackTrace.ToString();
try
{
EventLog.WriteEntry ("Sup", err, EventLogEntryType.Error);
Server.ClearError();
Response.Redirect("~/ErrorPage.aspx");
}
catch (Exception ex)
{
}
}
void Application_AuthenticateRequest(object sender, EventArgs e)
{
// Extract the forms authentication cookie
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)
{
// Log exception details (omitted for simplicity)
return;
}
if (null == authTicket)
{
// Cookie failed to decrypt.
return;
}
System.Security.Principal.GenericIdentity id = new System.Security.Principal.GenericIdentity(authTicket.Name, "LdapAuthentication");
// This principal will flow throughout the request.
System.Security.Principal.GenericPrincipal principal = new System.Security.Principal.GenericPrincipal(id, null);
// Attach the new principal object to the current HttpContext object
Context.User = principal