Solved

Why resonse.redirect cannot find my web form page?

Posted on 2011-03-13
7
305 Views
Last Modified: 2012-05-11
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
0
Comment
Question by:lapucca
7 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 250 total points
ID: 35125634
Is "Admin" in the root folder of your site? If so, try using the "root" indicator ( ~ ):
Response.Redirect("~/Admin/ManagerUsers.aspx");

Open in new window

0
 
LVL 39

Assisted Solution

by:Pratima Pharande
Pratima Pharande earned 250 total points
ID: 35125638
check your path and folder structure
http://localhost/Survey/Admin/ManagerUsers.aspx

is it like this

share your folder sturure for more clarity
0
 
LVL 17

Expert Comment

by:Shinesh Premrajan
ID: 35125672
/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
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 10

Expert Comment

by:Asim Nazir
ID: 35125721
Hi,

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

Asim
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 35125731
>>  Use ~ sign in your page path.

That sounds oddly familiar....
0
 
LVL 12

Expert Comment

by:starlite551
ID: 35125747
Use this code :
Response.Redirect("../Admin/ManagerUsers.aspx");

Open in new window

0
 

Author Comment

by:lapucca
ID: 35170355
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
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How come this regular expression allows "e"? 14 45
Release Dynamically Allocated Memory in C# 3 38
asp.net web application 3 29
asp.net mvc 2 25
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question