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

appconfig.json not found #3946


User avatar
0
kythor created

I'm trying to setup ASP.NET Core & Angular on my IIS server. I followed all the steps, but when I go to the angular site, I get a popup with "Resource not found" and in the F12 screen I see that it's looking for <a class="postlink" href="http:///assets/appconfig.json">http:///assets/appconfig.json</a>

but its there....

what to do?


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

    Hi @Kythor,

    Some server's does not ally json extension by default. You can add a webconfig to your website such as this one <a class="postlink" href="https://github.com/aspnetzero/aspnet-zero-core/blob/dev/angular/web.config">https://github.com/aspnetzero/aspnet-ze ... web.config</a> to allow accessing json file.

  • User Avatar
    0
    kythor created

    perfect, that worked.

    just another stupid question, what Url do I need to use for the end user UI? is it <a class="postlink" href="http:///app/main">http:///app/main</a> if I try that, I get an error:

    /AbpUserConfiguration/GetAll net::ERR_CONNECTION_TIMED_OUT

    update: now I get this error on every link/page...

  • User Avatar
    0
    kythor created

    nevermind, now it loads again... havent changed a thing though...

  • User Avatar
    0
    kythor created

    now the error again after trying to reload main url

    can anybody point me to the mechanism behind this? Can this be handled? because the end user will be using F5

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @rewrite,

    When you press F5, if you are not in the root url, it is not handled by angular. Then web.config I have shared before contains a rewrite rule. It redirects all paths to base url (/).

    Have you added it into your web.config ?

  • User Avatar
    0
    kythor created

    yes I'm using this web.config. But now it works again...

    I'm new with Angular, so excuse my limited knowledge.

  • User Avatar
    0
    kythor created

    errors again, this is frustrating, because I have not yet changed a line of code...

    i get a connection time out error now from just loading the site: :8080/AbpUserConfiguration/GetAll net::ERR_CONNECTION_TIMED_OUT

  • User Avatar
    0
    kythor created

    found this post: #4018@5c502c01-b478-4bea-b9c7-320840d7c879

    its part of the solution, since my appconfig.json on the host application was not correct, need to add client and host url to "CorsOrigins"

  • User Avatar
    0
    kythor created

    now however, when I added a tenant and try to go to the tenant url (eg <a class="postlink" href="http://tenant.domain.com">http://tenant.domain.com</a>) i get an error stating "CORS-header ‘Access-Control-Allow-Origin’ missing

    its looking for <a class="postlink" href="http://tenant.domain.com:8080/AbpUserConfiguration/GetAll">http://tenant.domain.com:8080/AbpUserCo ... ion/GetAll</a>

    since my RemoteServiceBaseUrl points to http://{tenancy_name}.domain.com:8080

    adding <a class="postlink" href="http://tenant.domain.com">http://tenant.domain.com</a> into CorsOrigins field of the host appsettings.json does not fix it

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @Kythor,

    Can you share your angular & host project configuration files ? I think this is because of a configuration problem.

  • User Avatar
    0
    kythor created

    Angular appconfig.json:

    {
      "remoteServiceBaseUrl": "http://{TENANCY_NAME}.mydomain.eu:8080",
      "appBaseUrl": "http://{TENANCY_NAME}.mydomain.eu"
    }
    

    Host appconfig.json:

    {
      "ConnectionStrings": {
        "Default": "Data Source=**;Initial Catalog=**;Persist Security Info=True;User ID=**;Password=**;MultipleActiveResultSets=True"
      },
    
      "Abp": {
        "RedisCache": {
          "ConnectionString": "localhost",
          "DatabaseId": -1
        }
      },
    
      "App": {
        "ServerRootAddress": "http://www.mydomain.eu:8080",
        "ClientRootAddress": "http://www.mydomain.eu",
        "CorsOrigins": "http://www.mydomain.eu,http://www.mydomain.eu:8080"
      },
    
      "Authentication": {
        "Facebook": {
          "IsEnabled": "false",
          "AppId": "",
          "AppSecret": ""
        },
        "Google": {
          "IsEnabled": "false",
          "ClientId": "",
          "ClientSecret": ""
        },
        "Microsoft": {
          "IsEnabled": "false",
          "ConsumerKey": "",
          "ConsumerSecret": ""
        },
        "JwtBearer": {
          "IsEnabled": "true",
          "SecurityKey": "**",
          "Issuer": "OPTA",
          "Audience": "OPTA"
        }
      },
    
      "Recaptcha": {
        "SiteKey": "**-**-",
        "SecretKey": "**-**"
      },
    
      "IdentityServer": {
        "IsEnabled": "true",
        "Clients": [
          {
            "ClientId": "client",
            "AllowedGrantTypes": [ "password" ],
            "ClientSecrets": [
              {
                "Value": "**"
              }
            ],
            "AllowedScopes": [ "default-api" ]
          },
          {
            "ClientId": "demo",
            "ClientName": "MVC Client Demo",
            "AllowedGrantTypes": [ "hybrid", "client_credentials" ],
            "RequireConsent": "true",
            "ClientSecrets": [
              {
                "Value": "**"
              }
            ],
            "RedirectUris": [ "http://openidclientdemo.com:8001/signin-oidc" ],
            "PostLogoutRedirectUris": [ "http://openidclientdemo.com:8001/signout-callback-oidc" ],
            "AllowedScopes": [ "openid", "profile", "default-api" ],
            "AllowOfflineAccess": "true"
          }
        ]
      },
    
      "Payment": {
        "PayPal": {
          "Environment": "sandbox",
          "BaseUrl": "https://api.sandbox.paypal.com/v1",
          "ClientId": "",
          "ClientSecret": "",
          "DemoUsername": "",
          "DemoPassword": ""
        }
      }
    }
    
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Can you try to change your Host config like this:

    "App": {
        "ServerRootAddress": "http://{TENANCY_NAME}.mydomain.eu:8080",
        "ClientRootAddress": "http://{TENANCY_NAME}.mydomain.eu",
        "CorsOrigins": "http://www.mydomain.eu,http://www.mydomain.eu:8080"
      }
    
  • User Avatar
    0
    kythor created

    doesnt work:

    Accept:/ Accept-Encoding:gzip, deflate Accept-Language:nl-NL,nl;q=0.8,en-US;q=0.6,en;q=0.4 Access-Control-Request-Headers:.aspnetcore.culture,abp.tenantid,authorization,content-type,x-requested-with Access-Control-Request-Method:GET Connection:keep-alive Host:lanista..eu: Origin:http://lanista..eu Referer:http://lanista..eu/ User-Agent:Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
    <HTML><HEAD><TITLE>Bad Request</TITLE>
    <META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
    <BODY><h2>Bad Request - Invalid Hostname</h2>
    <hr><p>HTTP Error 400. The request hostname is invalid.</p>
    </BODY></HTML>
    
  • User Avatar
    0
    kythor created

    however it does kind of work if I add the tenant url to my IIS (host name) bindings. but i guess that beats the purpose of auto tenant creation?

    and If I login successfully, I get an error on the Angular app, but not on the public mvc site...

  • User Avatar
    0
    kythor created

    and now after changing nothing but restarting IIS, i get the loading screen and after a while the message "an error has occured". In the F12 network screen there is even nothing, no GetAll or anything...

    it gets weirder and weirder.

    but the public mvc site loads without a problem... so is this an angular issue?

  • User Avatar
    0
    kythor created

    I updated both the angular and host to the latest version.

    Now I get "An error occured while starting the application" for the host app...

  • User Avatar
    0
    aaron created
    Support Team

    Can you show a screenshot and the error log?

  • User Avatar
    0
    kythor created

    in the meantime a have fixed it, it was a mixup of appconfig.json and IIS DNS config