Base solution for your next web application
Open Closed

ASP.NET Core & Angular Deployment Steps/Guide Help Required #3380


User avatar
0
gbadenhorst created

Hi,

Is there a specific or detailed guide that can be followed when deploying a ASP.NET Core & Angular application?

I have been struggling to deploy the API side for a while now and i know it is probably a stupid mistake on my side but i am out of ideas as from what i can see, it is not the basic deployment style of a normal MVC web app.

It keeps complaining about the webconfig not being in the correct format. Error provided by IIS: HTTP Error 500.19 - Internal Server Error

File attached with more details.

I don't know where i went wrong with the deployment as it was handle like any other.

Any help would be greatly appreciated.

Regards, Gideon Badenhorst.


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

    Hi,

    Actually, it should be same like publishing an simple MVC application.

    As I remember, there was a problem with web.config. When you open it with notepad++, there must be a strange character at the first line of it. IF you remove it, it should work.

    If it does not work, please share your web.config file (not it's content) ?

    Thanks.

  • User Avatar
    0
    gbadenhorst created

    Hi,

    I had a look at the config file and this is the part that is confusing me a bit with the ASP.Net Core side with the deployment.

    The config file contains almost no data as the config is done in the appsettings.json file.

    Within both the web.config and the appsettings.json i could not find any specific invalid char or anything that is blocking access.

    Since all the config is done in the appsettings.json file, should there be IIS config to handle the reroute to the appsettings file or something in that line.

    This is so far just trying to get the API hosted.

    <span style="color:#FF0000"><ins>Please see below the web.config file data:</ins></span>

    <?xml version="1.0" encoding="utf-8"?> <configuration>

    <a class="postlink" href="http://go.microsoft.com/fwlink/?LinkId=786380">http://go.microsoft.com/fwlink/?LinkId=786380</a>

    <system.webServer> <handlers> <add name="aspNetCore" path="" verb="" modules="AspNetCoreModule" resourceType="Unspecified"/> </handlers> <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/> </system.webServer> </configuration>

    <ins><span style="color:#FF0000">Please see below the appsettings.json data:</span></ins>

    { "ConnectionStrings": { "Default": "Server=Server Database=Database;User Id=User; Password=Password;" }, "Abp": { "RedisCache": { "ConnectionString": "localhost", "DatabaseId": -1 } }, "App": { "ServerRootAddress": "http://localhost:22742/", "ClientRootAddress": "http://localhost:4200/", "CorsOrigins": "http://localhost:4200,http://localhost:49152" }, "Authentication": { "Facebook": { "IsEnabled": "false", "AppId": "", "AppSecret": "" }, "Google": { "IsEnabled": "false", "ClientId": "", "ClientSecret": "" }, "Microsoft": { "IsEnabled": "false", "ConsumerKey": "", "ConsumerSecret": "" }, "JwtBearer": { "IsEnabled": "true", "SecurityKey": "HostingTemplate_8CFB2EC534E14D56", "Issuer": "HostingTemplate", "Audience": "HostingTemplate" } }, "Recaptcha": { "SiteKey": "6LfD-wUTAAAAACULAVXvL61K0w02RIsjhI8EyiS-", "SecretKey": "6LfD-wUTAAAAADm3h7vomd9FtaAlAwexki29BtXC" } }

    I redownloaded the later template now to use a clean version for deployment as a test with the same result.

    I also went through all of the guides for this specific template regarding config and setup to make sure i did not mis anything for the API and could not find anything that might cause problems.

    Thank you,

    Regards, Gideon Badenhorst.

  • User Avatar
    0
    gbadenhorst created

    The problem for the API side has been solved. Was a really stupid mistake on my side. If anyone ever gets this problem remember to change the app pool to unmanaged code instead of .net 4.0.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @GBadenhorst,

    Thanks for the feedback :). Do you have any problems regarding to angular side ?

    Thanks.

  • User Avatar
    0
    gbadenhorst created

    Hi,

    Yes i am currently having a problem with the Angular connection to the API.

    I have read through the posts on the site and most of the CORS related posts are mainly focused on the way the addresses are posted in the config.

    Attached there are 2 different types of issues i get only on deployed version and not when i debug.

    CORS issue is one of the big ones as it blocks me from deleting. I can however still do a GET on most things but there are some that give 500 errors as shown in the second attachment.

    I can create documents and get those documents that i created also without and issue. So far only my one process Stock movements and some standard things that comes with the template are giving the 500 error. technically there should not be any 500 errors from only certain items of the base template.

    I also hosted a standard blank template without any changes on it and still receive the 500 errors. on the audit log it links up this as the error is this something that is incorrect on template as i am yet to change anything: System.Data.SqlClient.SqlException (0x80131904): Incorrect syntax near 'OFFSET'. Invalid usage of the option NEXT in the FETCH statement. at System.Data.SqlClient.SqlCommand.<>c.<ExecuteDbDataReaderAsync>b__174_0(Task1 result) at System.Threading.Tasks.ContinuationResultTaskFromResultTask2.InnerInvoke() at System.Threading.Tasks.Task.Execute() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.<ExecuteAsync>d__26.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.EntityFrameworkCore.Query.Internal.AsyncQueryingEnumerable.AsyncEnumerator.<BufferlessMoveNext>d__9.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.EntityFrameworkCore.Storage.Internal.SqlServerExecutionStrategy.<ExecuteAsync>d__6`2.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.EntityFrameworkCore.Query.Internal.AsyncQueryingEnumerable.AsyncEnumerator.

    Is there something that i might be doing wrong as the application should already be CORS enabled and should not require further config for that except for the addresses specified in config?

    Below is my address config in appconfig.json and appsettings. json: appsettings.json: "Abp": { "RedisCache": { "ConnectionString": "localhost", "DatabaseId": -1 } }, "App": { "ServerRootAddress": "https://127.0.0.1:22742", "ClientRootAddress": "https://127.0.0.1:4200/", "CorsOrigins": "https://127.0.0.1:4200/,https://127.0.0.1:22742" }, AppConfig.json { "remoteServiceBaseUrl": "https://127.0.0.1:22742", "appBaseUrl": "https://127.0.0.1:4200/" }

    Is there another part of unmentioned config that might need to be done on the server or is it maybe something that is beign done wrong app related?

    My hosting is done on a Windows 10 PC and the publicIP:Port routes everything to that pc relating to the above ports.

    Thank you.

    Regards, Gideon Badenhorst.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Your configuration seems correct. One thing, you don't need to add <a class="postlink" href="https://127.0.0.1:22742">https://127.0.0.1:22742</a> to CorsOrigins setting.

    Which version of ABP do you use in your project ? As I remember there was a bug related to CorsOrigins setting value. Can you try to set it to "https://127.0.0.1:4200" withoud ending "/" ?

    Also which db do you use ? Can you write it's version as well like SQL Server 2012 ?

    Thanks.

  • User Avatar
    0
    gbadenhorst created

    Hi,

    Sorry for only getting back now.

    The SQL version is: SQL Server R2 2008. I have found out however that some features are not supported by the 2008 such as Take and Skip. This was what caused the 500 Error.

    I moved the database to a hosting company instead of at the client self.

    By the looks of it the CORS problem has been solved also. it was something with the IP config and slashes as you mention.

    Now that i have the hosting sorted with a base template i will be moving my content to it and hopefully not encounter more issues xD

    Thank you very much for all the assistance.

    Regards, Gideon Badenhorst.

  • User Avatar
    0
    gbadenhorst created

    Hi,

    It seems like i was wrong.

    PublicIP:22742//api/services/app/OrganizationUnit/DeleteOrganizationUnit?Id=2&:1 DELETE <a class="postlink" href="http://PublicIP:22742//api/services/app/OrganizationUnit/DeleteOrganizationUnit?Id=2&">http://PublicIP:22742//api/services/app ... Unit?Id=2&</a> 405 (Method Not Allowed) organization-units:1 XMLHttpRequest cannot load

    <a class="postlink" href="http://PublicIP:22742//api/services/app/OrganizationUnit/DeleteOrganizationUnit?Id=2&">http://PublicIP:22742//api/services/app ... Unit?Id=2&</a>. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://PublicIP:4200' is therefore not allowed access. The response had HTTP status code 405.

    I tried to do an updated and the CORS still gives problems.

    Regards, Gideon Badenhorst

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Do you host your app on azure or any other provider ? If it is on azure and if you configured CORS settings an azure, your local settings on appconfig.json will not work.

    If it is different, we can try to help you if you can share your *.Web.Host and Angular project setting files via email (<a href="mailto:[email protected]">[email protected]</a>).

    Thanks.

  • User Avatar
    0
    gbadenhorst created

    Good morning,

    Apologies for the late reply.

    We use standard IIS hosting.

    I will be at my client again during this week and will share the details as soon as i can.

    Is there a way to use these templates without CORS?

    Regards, Gideon Badenhorst

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Actually CORS is managed by ASP.NET Zero. We allow only specific websites in here <a class="postlink" href="https://github.com/aspnetzero/aspnet-zero-core/blob/dev/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Web.Host/Startup/Startup.cs#L62">https://github.com/aspnetzero/aspnet-ze ... tup.cs#L62</a>.

    You can modify this section of code to allow any website to access *.Web.Host project's website. I don't know how to do it but you can find it on the web I think if you search for ASP.NET Core and CORS.

    Thanks.