Last post May 22, 2008 02:20 PM by the_web_coder
May 10, 2008 07:55 AM|sreedath|LINK
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
//method1 populates the cookie with values from a DB call
//the code below is a sample
Thank you in advance!
May 10, 2008 08:36 AM|DigiMortal|LINK
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
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.
May 11, 2008 10:26 AM|sreedath|LINK
Thank You DigiMortal for the reply.
But again won't there be a infinite loop?What if the requested path is ../AdminDashBoard.aspx and the user needs to be redireced to the same page?Sorry if I have misunderstood your answer.Might be sample code will help
The way I tackled the issue is by redirecting to a common page LandingDashBoard(Non-Existent).And checking if the request is for LandingDashBoard.aspx,then redirect to the specific dashboard page depending on the role.But this again suffers from the issue
that if the user comes to know of the url of admin page then he will be able to browse it.
Is there a better way or better place to put in this logic??
May 11, 2008 11:26 AM|DigiMortal|LINK
May 12, 2008 02:00 AM|sreedath|LINK
DigiMortal the problem is there is no DashBoard.aspx.We have only two pages AdminDashBoard.aspx and UserDashboard.aspx.I am only trying to check if the user has requested for one of the DashBoard pages?
if he is being redirected to the correct page is there a way to stop the flow going back to the begin request handler?
May 15, 2008 08:37 AM|docluv|LINK
May 15, 2008 11:51 AM|DigiMortal|LINK
This one doesn't work if application is not in site root. And if it is, it asks teh file /dashboard.aspx
Before trying hacks try to get file name from Request properties. It should be there even if file doesn't exist.
If you want to extract file name from RawUrl then follow these steps:
May 22, 2008 07:53 AM|sreedath|LINK
Hi Thx for the reply and sorry for the delay in getting back.The solution that you gave does solve the problem.
Can you also advice on the below point:
the http module is being hit for all the calls(even the posback) so this piece of logic is run every time the page has a postback.Is there a way to solve this .Can we put the same code in a better place like global.asax? or check if the call is a postback
May 22, 2008 12:41 PM|DigiMortal|LINK
May 22, 2008 02:20 PM|the_web_coder|LINK
I may be way off here but would it not be better to setup a handler instead and set the path to dashboard.aspx this way your code will only be called when a request to dashboard.aspx is made instead of through a module which is called for every request,
if you go down this route you cut your code down to just checking the user and doing the appropiate redirect.