Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: C#
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
Posted 30-Jan-13 0:16am
Edited 30-Jan-13 1:35am
Rahul Dhoble at 30-Jan-13 5:41am
Amrutha , I just you to improve question with some better word include some more examples

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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 at 30-Jan-13 7:21am

i understand what you meant .I added a ~/ before returnurl and its working fine. thanks Ankur
Ankur\m/ at 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)

Advertise | Privacy | Mobile
Web02 | 2.8.150301.1 | Last Updated 30 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100