Base solution for your next web application
Open Closed

.NET Core MVC - Virtual Directory under root of website #3115


User avatar
0
cmthomps created

Having an issue deploying to a virtual directory that is not the root of the website in IIS. When we deploy, the app renders fine by the service calls have the incorrect URL. Example:

Deploying site to: <a class="postlink" href="http://www.test.com/aspnetzero">http://www.test.com/aspnetzero</a>

When the site renders in the browser, the api calls are made to: <a class="postlink" href="http://www.test.com/api..">http://www.test.com/api..</a>.

Instead of: <a class="postlink" href="http://www.test.com/aspnetzero/api">http://www.test.com/aspnetzero/api</a>

Is there some configuration I can change to make it work? We've already changed web.config to contain:

"App": { "WebSiteRootAddress": "http://www.test.com/aspnetzero/" },

Thanks


2 Answer(s)
  • User Avatar
    0
    cmthomps created

    Well, I found a workaround but I'm not sure if it's the appropriate solution.

    In the _Layout.cshtml file there is this code:

    &lt;script type=&quot;text/javascript&quot;&gt;
        @* This is used to get the application's root path from javascript.
        It's useful if you're running application in a virtual directory under IIS. *@
        var abp = abp || {}; abp.appPath = '@ApplicationPath';
    &lt;/script&gt;
    

    If I change it to:

    &lt;script type=&quot;text/javascript&quot;&gt;
        @* This is used to get the application's root path from javascript.
        It's useful if you're running application in a virtual directory under IIS. *@
        var abp = abp || {}; abp.appPath = '@ApplicationPath' + 'aspnetzero/';
    &lt;/script&gt;
    

    It works.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Your solution is fine at the moment. As I see, this is not implemented yet, see <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/blob/master/src/Abp.AspNetCore/AspNetCore/Mvc/Views/AbpRazorPage.cs#L26">https://github.com/aspnetboilerplate/as ... age.cs#L26</a>.

    We will try to do it soon,

    Thanks.