hello every body !
i am trying to correct this error/bug what ever call it ?
i am using asp.net 1.1
the aim is to transfer the page to some other page from http module i have tried all that i know and all the ways work but the problem is when i request the page seconding time ( without rebuilding ) i get an unexpected results . note that both the all alternatives which i will present here the same problem i.e first time works and second time fails.
1 . using server.transfer
first time works , but second time fails
the handler for the event BeginRequest is
void BeginRequestHandler(object sender, EventArgs e)
{
char[] CharOnWhichToParse = {'/'};
String[] requestparts = CurrentContext.Request.Path.Split(CharOnWhichToParse);
//get an object of type CustomSectionOfItimSecurity filled with values with //respect to values
//in "system.web/itimSecurity"
ItimSecuritySectionData temp = (ItimSecuritySectionData)CurrentContext.GetConfig("system.web/itimSecurity");
if (temp.SecurityEnabled.Equals(true))
{
foreach(Object o in temp.GetPageNames)
{
String pageName = (String)o;
if ( pageName.Equals(requestparts[requestparts.Length-1]))
{
CurrentContext.Server.Transfer("MyLoginPage.aspx");
}
}
}
}
error is "Object reference not set to an instance of an object. "
line is "CurrentContext.Server.Transfer("MyLoginPage.aspx");"
2 .
using CurrentContext.Request.Path.Replace(requestpart[requestparts.Length-1],"MyLoginPage.aspx"); instead of server.transfer
this time in this method first time works while 2nd time on debugging i found that
String[] requestparts = CurrentContext.Request.Path.Split(CharOnWhichToParse);
return requestparts[requestparts.length-1] = "MyLoginPage.aspx"
in short please post me any working code in httpmodule habndler which transfers to some other page