Click here to Skip to main content
14,735,594 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all

Im redirecting pages to index.aspx page which is inside a folder employee and the url is my home page is in hr folder hr.aspx problem is when redirecting url with querystring return url
if (Request.QueryString["ReturnUrl"] == null)
    returnUrl = "~/hr/hr.aspx"
    returnUrl = Request.QueryString["ReturnUrl"];

im using this code.but else part leads to exception return url concatenates with abc folder like instead i want .
if my return url with querysting is like this" when login error arising with the code given above url redirects to but i want this to direct to

why happening so? How to overcome this

Thanks in Advance
Updated 30-Jan-13 1:35am
RDBurmon 30-Jan-13 5:41am
Amrutha , I just you to improve question with some better word include some more examples

1 solution

That's because you are using incorrect relative URL.
When you say hr/bonus.aspx, the URL that will be generated will be respective of your current path.
So say you have a site
You are currently on a page somepage.aspx which is inside pages folder -
Now if you create a relative URL like hr/otherpage.aspx, your URL will be

To solve this issue, you will need to specify the path relative to the root directory. You do that using a leading slash (/).
So instead of hr/bonus.aspx use /hr/bonus.aspx and it should be fine.

Let me know if you don't understand.
amritha444 30-Jan-13 7:21am
i understand what you meant .I added a ~/ before returnurl and its working fine. thanks Ankur
Ankur\m/ 30-Jan-13 7:32am
What you had was a string. So I suggested leading slash (/) rather than ~/
Anyways glad that I could help. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900