0

I have three applications (written in C#) hosting under one domain e.g. example.com/app1 example.com/app2 example.com/app3 through IIS. There is nothing present at the root e.g. at example.com

Would it be possible for one of those applications to be accessed when someone tries to reach the root at example.com? Currently a 403 gets thrown if I try to access the root.

Tim Morris
  • 385
  • 1
  • 3
  • 11
  • Possible duplicate of [How to redirect a URL path in IIS?](https://stackoverflow.com/questions/888325/how-to-redirect-a-url-path-in-iis) – GSerg Dec 05 '19 at 15:54
  • I was hoping it would be possible in C# code rather than IIS configuration. – Tim Morris Dec 05 '19 at 16:05
  • You said there is no app at the root, so no C# code to begin with. You can write yet another C# app and put it into the root to perform the redirection. – GSerg Dec 05 '19 at 16:09
  • I might be forced to do that, yeah. Oh well. – Tim Morris Dec 05 '19 at 16:50

1 Answers1

1

In my opinion, you could write a asp.net application e.g webform or MVC or else at the root of the example.com website in the IIS.

For the webform.

You could create a index.aspx page in the root path.

Then you could use response.redirect to redirect the url to one of your application.

Details codes as below:

public partial class welcome : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Redirect("http://example.com/app1");
    }
}
Brando Zhang
  • 22,586
  • 6
  • 37
  • 65
  • That's what I'm settling on, yeah. I'll have to run it by the software architects though, since it's adding IIS configuration. Alas. – Tim Morris Dec 07 '19 at 00:53