Solved

Why resonse.redirect cannot find my web form page?

Posted on 2011-03-13
7
296 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 74

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:shinuq
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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 74

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now