Hi,
There are two pages one for the Admin and other for the normal user.Depending on the user they need to be redirected to a different page.I am writing the logic for the redirection in the httpmodule beginrequest handler.Both the pages share a common suffix(dashboard).But on being redirected I am entering into an infinite loop.Is there a way to stop the iteration once the redirection is done the first time??I am attaching a sample code
void context_BeginRequest(object sender, EventArgs e)
{
//method1 populates the cookie with values from a DB call
//the code below is a sample
if(HttpContext.Current.Request.RawUrl.Contains("Dashboard.aspx"))
if(user=="Admin")
{
HttpContext.Current.RewritePath("AdminDashboard.aspx");
}
else
{
HttpContext.Current.RewritePath("UserDashboard.aspx");
}
}
}
Thank you in advance!
Yes, you must be in infinite loop. You are checking if url contains Dashboard.aspx. Both - AdminDashboard.aspx and UserDashboard.aspx contain Dashboard.aspx. Instead of
if(HttpContext.Current.Request.RawUrl.Contains("Dashboard.aspx"))
you should check out if request is made to page calles Dashboard.aspx. To do this you have to check Reuqest object's path properties.