Nagelfar
Nagelfar

Reputation: 813

Response.Redirect with a subdirectory in url

I have a little problem with my Redirect in ASP.NET (C#)

I just got a domain which looks like this: http://www.example.com/subdirectory

So when I open my asp.net start page, the url looks like this: http://www.example.com/subdirectory/Startpage/Startpage.aspx

That's my Redirect in code behind:

Response.Redirect("~/UserSite/UserSite.aspx")

The problem now is, when I click on that button, I get redirected to

http://www.example.com/UserSite/UserSite.aspx

instead of

http://www.example.com/subdirectory/UserSite/UserSite.aspx

How can I get my web page to notice the subdirectory in the url?

Would be nice if someone could help me. Thanks.

Upvotes: 2

Views: 1777

Answers (1)

Aki
Aki

Reputation: 626

This may be because your website under the sub-drecitory hasn't been setup as it's own application within IIS7.

You can do this by:

  1. Open IIS Manager
  2. Open up the website and right click on the sub directory
  3. Click on "Convert to Application"
  4. You can then change the Application Pool if you wish to have a dedicated one or otherwise just click OK.

Response.Redirect("~/UserSite/UserSite.aspx") should then understand that /subdirectory/ is the default website directory

Upvotes: 2

Related Questions