Click here to Skip to main content
13,001,686 members (90,422 online)
Rate this:
Please Sign up or sign in to vote.
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
Posted 29-Jan-13 23:16pm
Updated 30-Jan-13 0:35am
Rahul Dhoble 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 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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170624.1 | Last Updated 30 Jan 2013
Copyright © CodeProject, 1999-2017
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