Richard77
Richard77

Reputation: 21651

How to make Response.Redirect consistent across environment?

This line works just fine when I run it in my visual studio.

Response.Redirect("/MyFolder/MyPage.aspx?param=n")

However, it's behaving in a stange way in the test server. The reason for the error is that the structure is not the same in the test server compared to my visual studio. The solution is in server is inside another folder.

OuterFolder/MyFolder/MyPage.aspx?param=n

So the server is expecting something like: mydomain.com/OuterFolder/MyFolder/MyPage.aspx?param=n

But the request sent is like:mydomain.com/MyFolder/MyPage.aspx?param=n

That's why I'm getting a 404.

I supposed there must be a way to take into account the path no matter how deep the solution is in folders.

Upvotes: 0

Views: 19

Answers (2)

DaniDev
DaniDev

Reputation: 2631

I am going to assume that you have set up OuterFolder as an Application/Virtual Dir under your default website(?).

In which case you should try this:

Response.Redirect("~/MyFolder/MyPage.aspx?param=n")

Upvotes: 0

IrishChieftain
IrishChieftain

Reputation: 15253

Have you tried resolving it from the application root?

Response.Redirect("~/MyFolder/MyPage.aspx?param=n")

Upvotes: 2

Related Questions