Web.Config for SubDomains using ASP.NET Core Web App

Discussion in 'General troubleshooting' started by Jay Shaw, Apr 5, 2020.

  1. Hello,

    I need help getting a subdomain to work in my domain. Here's what I've done:

    1. Using an FTP program, I created two subfolders in my root folder: WebApp1 and WebApp2

    2. From the Winhost Control Panel, I created two Subdomain Pointers: WebApp1.MyDomain.Com pointing to subfolder WebApp1 and WebApp2.MyDomain.Com pointing to subfolder WebApp2

    3. Using VS2019Pro I created an ASP.NET Core Web Application, called WebApp1, and successfully used Web Deploy to upload it to the WebApp1 subfolder.

    4. Using a text editor and FTP program I created a simple index.html page and put it in the WebApp2 subfolder.

    5. In the root of mydomain.com I made a Web.Config file that looks like this:

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
    <system.webServer>
    <rewrite>
    <rules>

    <rule name="webapp1.mydomain.com">
    <match url=".*" />
    <conditions>
    <add input="{HTTP_HOST}" pattern="^webapp1.mydomain.com$" />
    <add input="{PATH_INFO}" pattern="^/webapp1/" negate="true" />
    </conditions>
    <action type="Rewrite" url="\webapp1\{R:0}" />
    </rule>

    <rule name="webapp2.mydomain.com">
    <match url=".*" />
    <conditions>
    <add input="{HTTP_HOST}" pattern="^webapp2.mydomain.com$" />
    <add input="{PATH_INFO}" pattern="^/webapp2/" negate="true" />
    </conditions>
    <action type="Rewrite" url="\webapp1\{R:0}" />
    </rule>

    </rules>
    </rewrite>
    </system.webServer>
    </configuration>​

    Now here's the result:

    * Going to http://webapp1.mydomain.com, (ASP.Net project) I get a totally blank screen. No webpage. No error. However, when I go to http://www.mydomain.com/webapp1 it works totally fine. I see the ASP.Net Core App that I wrote and it works exactly as I want it to.

    * Meanwhile, going to http://webapp2.mydomain.com, (text editor project) it works flawlessly. So, I know the web.config file is working for a very simple target website, but it's NOT workign when I redirect to the far more complex ASP.Net web application at WebApp1.

    What am I doing wrong? Is there something wrong with my web.config file?

    Thank you for any help and/or suggestions!

    Jason
     
  2. Elshadriel

    Elshadriel Winhost Staff

    Does webapp1 use routing? (e.g. MVC, WebApi) That can cause problems.
     
  3. Yes, I believe it must since it's a standard ASP.Net Core Web Application built in Visual Studio 2019 Pro. Basically, just built the project using the template and then deployed it.

    I know that inside the WebApp1 subfolder, there is also a wwwroot subfolder. I tried changing my root web.config to point to that, but that doesn't work either.

    It's like the web.config takes me to t he e right place, but then WebApp1 doesn't process my request for a webpage and so I get a blank screen.
     
  4. Elshadriel

    Elshadriel Winhost Staff

    Yeah. I'm not sure why it's not working. But routing (.NET Core/Framework) can cause issues if your routes are not setup correctly. Have you tried looking at Chrome's Developer tools to see if it's generating any errors?
     
  5. Four years later, and there are still no suggestions in the Winhost knowledge base for configuring .NET Core web apps.

    I’m experiencing the same issue when trying to run the default, out-of-the-box Weather app provided by Microsoft for a new .NET Core Razor project.
    This app doesn’t include any custom middleware or modifications.
     

Share This Page