Redirect to a page in other folder

Hi all,

How can I run the command Redirect to a page in another folder?

Clarifying. Suppose that I have a AA folder that contains the BB and CC subfolders. One ASP.NET page located in the directory and BB need redirect to another page in the folder CC. What is the correct command to do it?

It may be a simple question, but I'm struggling to solve it.

Thanks, Marcelo Camarate
Marcelo CamarateAsked:
Who is Participating?
 
MlandaTCommented:
Mine seems to be working.... Look here... I only now made it display the time in your label in the Page_Load. You will see that the time changes. I only changed Default.aspx.vb in first project.

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Me.Label1.Visible = True
        Label1.Text = "Page Load was called at: " & Now.ToString("dd/MMM/yyyy HH:mm:ss")

    End Sub


Works like a charm!
RedirectTest.zip
0
 
MlandaTCommented:
You could just start all redirects from the application root:

Response.Redirect("~/AA/CC/Page.aspx")

The special character "~" tells ASP.NET to just start from the root of the applicaiton which solves the problem
0
 
Marcelo CamarateAuthor Commented:
Hi MlandaT,

Thanks for your reply.

Sorry but, In the first message, I have not explained right my problem.

I am developing applications in ASP.NET using VB 2005. When I put the subfolders in the same Visual Studio (VS) project, all works OK. But, as my solution is composed of several systems, for organization reasons, I decided divide them into various designs VS. And that's my problem. When I redirect a page of another VS project don't work.

For a better understanding of my problem, I am attaching a small VS solution as an example.When I press the button "Go to Folder1 in the Same VS Project" on the Main Page, the browser goes to the page. But when I press the button "Go to other VS Project", a error window is shown, like below the image attached.

Can You help me, please?

Regards, Marcelo Camarate
RedirectTest.zip
Error.jpg
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

 
MlandaTCommented:
For now... delete the <authentication mode="Windows" line in ALL web.config files from the SUB applications. I understand exactly what you are trying to do here. I do it a lot (in commercially deployed applications). For the error message in the image above, there are a few things you will need to keep in mind:

1) It is allowed to have more than a single web.config in an application, however, some settings cannot be put into the sub folder web.config files. They have to be in the main web.config.

2) You need to think about the "\bin" folders... when your applicaiton redirects to a sub folder application, .NET will expect to find ALL the necessary DLLs in the \bin folder of the topmost web application. Now, in order to get around this, you will need to add folders to the probingPath http://msdn.microsoft.com/en-us/library/823z9h8w.aspx

<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <probing privatePath="plugins;dependencies"/>
    </assemblyBinding>
  </runtime>
</configuration>

3) You will need to keep in mind that when in your sub-applicaitons, the "~" will behave differenty... it will refer to the topmost folder...

I haven't yet downloaded your sample app yet. I'll do that shortly.
0
 
Marcelo CamarateAuthor Commented:
hi MlandaT,

Thank ypu for your reply.

In relationship of your second orientation about the necessity of inclusion "probing privatePath"  parameters, what web.config file I need add it? The existent in the subfoldes, the topmost folder or all?

Regards, Marcelo Camarate
0
 
MlandaTCommented:
Sorry for the late response... you need to add it to the topmost.
0
 
Marcelo CamarateAuthor Commented:
Hi MlandaT,

Thank you for your reply. I made your recommended changes in the topmost web.config file, but still occured an error, as the image attached.

I am attaching a new version of my VS solution example already with the changes in web.config file. Could you make a big favor? Download it, check what I'm doing wrong, and then return it changed? I appreciate it a lot.

Regards, Marcelo Camarate
Error.jpg
RedirectTest.zip
0
 
MlandaTCommented:
Oops! I forgot to tell you one other extremely important bit... in all the *.aspx, *.ascx pages in the sub project, you will need to include this line right at the top:

<%@ Assembly Name="Project1" %>

I have done that in the project you sent and it's now working perfectly.
Redirect.zip
0
 
Marcelo CamarateAuthor Commented:
Hi MlandaT,

Thank you for your reply. It worked OK.

But, as my intention is to deployed commercial applications, will have more of a project subfolder. So, I changed the example solution to include one more project. And this is my current problems.

On the main page, when a call the Project 1, works OK. But, when I call the Project 2, gives the error "Could not load file or assembly 'Project2' or one of its dependencies. The system cannot find the file specified". I included the first line <%@ Assembly Name="Project2" %> in the Default.aspx file Project 2.

Please, what is my error now?

Regards, Marcelo Camarate
Redirect.zip
0
 
MlandaTCommented:
<probing privatePath="Project1\bin"/>

should now include Project2

<probing privatePath="Project1\bin;Project2\bin"/>

I am unfortunately not aware of any other mechanisms to avoid having to do this apart from:

1) Copying all the files from the \bin folders of the sub applications into the topmost \bin folder (this actaully works quite well)
2) You should be able to create subfolders in the topmost \bin folder if you want to maintain segregation of the various individual project's files (I havent tried this)

3) You could also investigate the possibility of setting the probingPath programmatically... although much of my research indicated that this was not feasible since the probingPath is loaded right at the start of the loading of the appdomain and could not be modified... however... I did limited research on this and perhaps there are methods to achieve this.
0
 
Marcelo CamarateAuthor Commented:
Hi MlandaT,

I really forgot to add the Project2/bin folder in the "probing privatePath" parameter in the web.config file, and this mechanism isn't a problem for me.

But, have another problem with this mechanism. I don't know why, but the Sub Page_Load is not running when I pressing the buttons that called  Project 1 or Project 2 pages. That is, the pages are loaded without execute the Page_Load.

To demonstrate this problem, I am attaching the sample VS solution with a message about it.

Regards, Marcelo Camarate
Redirect.zip
0
 
Marcelo CamarateAuthor Commented:
Hi MlandaT,

Thanks for your reply.

Was not working before because I forgotten to publish the project. Now everything is working OK.

Again, thank you very much for your help. It was essential to solve my problem.

Regards, Marcelo Camarate
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.