Link to home
Start Free TrialLog in
Avatar of lapucca
lapucca

asked on

Why resonse.redirect cannot find my web form page?

Hi, I'm using asp.net 3.5 and C#.  I'm running this from VS 2008 in Debug mode.
I have the following code to verify the role after the user logs in (not windows id log in using Active Directory.  I'm using sql).  I log in as a Administrator but it cannot find the page.  Does Response.Redirect requires full http address? In the VS solution explorer, I have a Admin folder that has  a web form, ManagerUsers.aspx.  Why can't it find it?  Thanks.
thanks
    protected void loginAdapt_LoggedIn(object sender, EventArgs e)
    {
        if (Roles.IsUserInRole(loginAdapt.UserName, "Administrator"))
            Response.Redirect("/Admin/ManagerUsers.aspx");
        else if (Roles.IsUserInRole(User.Identity.Name, "Patient"))
        {
           
Server Error in '/Survey' Application.
--------------------------------------------------------------------------------

The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly.

Requested URL: /Survey/Admin/ManagerUsers.aspx


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.4952; ASP.NET Version:2.0.50727.4955
ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
/Survey/Admin/ManagerUsers.aspx

Is your file path correct, try testing the URL in the web browser and then paste that URL in the script.

The problem is with the file path the you have mentioned in the script, its going to a unknown place in the server.

Hope this helps
Hi,

Use ~ sign in your page path. Like:
Response.Redirect("~/Admin/ManagerUsers.aspx

Asim
>>  Use ~ sign in your page path.

That sounds oddly familiar....
Use this code :
Response.Redirect("../Admin/ManagerUsers.aspx");

Open in new window

Avatar of lapucca
lapucca

ASKER

I used '~' and '/' and still gets the same error.  My path is C:\Projects\AdaptSurvey\Admin\ ManagerUsers.aspx.  The internet is trying to find it here  http://localhost:49509/AdaptSurvey/Admin/ManagerUsers.aspx
I do restrict only login user with Admin role to enter in the web.config under this folder.  Would that be a problem?  Attached is my code.  thank you.

ManageUsers.aspx
ManageUsers.aspx.cs
Web.config
Login.aspx.cs