Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

After Deployment on Azure Urls Not working if hit directly #2722


User avatar
0
walkerscott created

I have deployed application client: mydomain.com/index.html server: mydomain.com

so for server I have used Visual studio publish and for client(ng2) I have used ng build --prod and copied files under from dist folder to wwwroot(folder on azure).

It works fine but when I go and hit some specific url it donot work, like if I share you url <a class="postlink" href="http://mydomain.com/app/admin/users">http://mydomain.com/app/admin/users</a> and as you to click and navigate you will see no page coming up.

So the problem is client is deployed at mydomain.com/index.html and routing is considering mydomain.com base url. Let me know whats the quick fix to this problem as I'm unable to share url of specific page. Thanks.

(PS: This is not a merged solution where we can deploy both client and server using visual studio)


14 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    The angular client project contains a web.config file. Can you also copy it to azure and try again ?

  • User Avatar
    0
    walkerscott created

    Yes following web.config is already there.

    <?xml version="1.0"?>
    <configuration>
        <system.webServer>
            <staticContent>
                <mimeMap fileExtension=".json" mimeType="application/json" />
            </staticContent>
            
            <rewrite>
              <rules>
                <rule name="Angular Routes" stopProcessing="true">
                  <match url=".*" />
                  <conditions logicalGrouping="MatchAll">
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    <add input="{REQUEST_URI}" pattern="^/(api)" negate="true" />
                  </conditions>
                  <action type="Rewrite" url="/" />
                </rule>
              </rules>
            </rewrite>        
        </system.webServer>
    </configuration>
    
  • User Avatar
    0
    walkerscott created

    Am I missing some configuration in this web.config? let me know the possible fix for this particular issue.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Can you send your website address to <a href="mailto:[email protected]">[email protected]</a> ?

    Thanks.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    I have tried same scenarion in local IIS and I got the same error. In order to deploy both server & client apps in same IIS application, you need to do below changes in your project.

    1. Use this web.config
    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      
      <system.webServer>
        <handlers>
          <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
        </handlers>
        <aspNetCore processPath=".\MyCompanyName.AbpZeroTemplate.Web.Host.exe" arguments="" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" />
        <rewrite>
          <rules>
            <rule name="Angular Routes App" stopProcessing="true">
              <match url="app/.*" />
              <conditions logicalGrouping="MatchAll">
                <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                <add input="{REQUEST_URI}" pattern="^/(api)" negate="true" />
              </conditions>
              <action type="Rewrite" url="/index.html" />
            </rule>
            <rule name="Angular Routes Account" stopProcessing="true">
              <match url="account/.*" />
              <conditions logicalGrouping="MatchAll">
                <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                <add input="{REQUEST_URI}" pattern="^/(api)" negate="true" />
              </conditions>
              <action type="Rewrite" url="/index.html" />
            </rule>
          </rules>      
        </rewrite>
      </system.webServer>
    </configuration>
    
    1. in angular2 app's config (appconfig.json), you need to add /index.html to appBaseUrl like this.
    http://mywebsite.com/index.html
    

    This change will break some parts of app (signalr & switching linked accounts as I tested).

    1. To fix signalr problem, open SignalRHelper.ts and in this line
    jQuery.getScript(AppConsts.appBaseUrl + '/assets/abp/abp.signalr.js');
    

    remove "index.html" from AppConsts.appBaseUrl . You can also define another AppConsts.appBaseUrl for example AppConsts.appRawBaseUrl and set it to "http://mywebsite.com" and use it in such places.

    1. To fix linked account problemopen linked-account.service.ts and in this line
    var targetUrl = this._appUrlService.getAppRootUrlOfTenant(result.tenancyName) + "?switchAccountToken=" + result.switchAccountToken;
    

    remove ending / character from this._appUrlService.getAppRootUrlOfTenant(result.tenancyName).

    If I can find a better routing configuration I will send you.

    Thanks.

  • User Avatar
    0
    walkerscott created

    I have followed these directions but still not working for me. Is there any missing step? I have updated xml, and in my appconfig file appbaseUrl was already like example.com/index.html

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Do you have a specific error ?

  • User Avatar
    0
    walkerscott created

    There is no specific error but the problem is still persisting. Can't navigate directly to specific url.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Can you grant us temporary access to your azure website ? So, we can check it. If you can, please send necessary inforamtion to <a href="mailto:[email protected]">[email protected]</a>.

    An FTP connection will be enough.

    Thanks.

  • User Avatar
    0
    walkerscott created

    My apologies for replying late, please find the associated publish profile which contains the details to login. Once we are finished with troubleshooting, will reset the publish profile We are on a critical path to deliver so your attention will be greatly appreciated!

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Did you send it via email ? If so, can you share the email address which you send from ? I couldn't find your email.

    Thanks.

  • User Avatar
    0
    walkerscott created

    Email sent, from <a href="mailto:[email protected]">[email protected]</a>

  • User Avatar
    0
    walkerscott created

    Hi guys, sent through a follow up email post deployment from <a href="mailto:[email protected]">[email protected]</a>

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    I think this problem is fixed via remote support.