Base solution for your next web application
Open Closed

Newly Deployed ASP.NET Core API to Azure: Error?statusCode=404 #9890


User avatar
0
MarkEaston created

Product Version: v9.2.1 Product Type: Angular Framework: .NET Core

Issue: when I go to https://cc-api-svc-p-aue.azurewebsites.net/ it keeps redirecting to Error?statusCode=404.

I have just deployed server side to Azure. I have done this before with oyther ASP.NET Zero webapps, but this time I just cant get it to work. The database connection is fine. Nothing is being written to log.txt

I have a har file but I cant see how to attach it to this issue.


10 Answer(s)
  • User Avatar
    0
    MarkEaston created

    As there is no way to attach files to your issues - I will instead attach a snip of then Dev Tools Network page:

  • User Avatar
    0
    MarkEaston created

    This is becoming quite frustrating. Its working perfectly locally. I cant move forward without getting this into azure.

    I have checked it against my other ASP.NET Zero webapp - https://ef-hubapi-svc-t-aue.azurewebsites.net (which works perfectly fine) - and I cant see any differences.

    I have checked my Azure Devops build and release pipelines and they match the ones I have for https://ef-hubapi-svc-t-aue.azurewebsites.net.

    So why is https://cc-api-svc-p-aue.azurewebsites.net/ not working???

  • User Avatar
    0
    MarkEaston created

    I see this exception, but my db connection string is ok - I have even had that connection string checked in Azure using their diagnostic tools ....

    · at Microsoft.Data.SqlClient.SqlConnectionString..ctor

    · at Microsoft.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions

    · at Microsoft.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup

    · at Microsoft.Data.SqlClient.SqlConnection.ConnectionString_Set

    · at Microsoft.Data.SqlClient.SqlConnection.set_ConnectionString

    · at Microsoft.Data.SqlClient.SqlConnection..ctor

    · at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerConnection.CreateDbConnection

    · at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.get_DbConnection

    · at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.Open

    · at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.BeginTransaction

    · at Microsoft.EntityFrameworkCore.RelationalDatabaseFacadeExtensions.<>c__DisplayClass26_0.<BeginTransaction>b__0

    · at Microsoft.EntityFrameworkCore.ExecutionStrategyExtensions.<>c__DisplayClass12_02.<Execute>b__0

    · at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.Execute[TState,TResult]

    · at Microsoft.EntityFrameworkCore.ExecutionStrategyExtensions.Execute[TState,TResult]

    · at Microsoft.EntityFrameworkCore.ExecutionStrategyExtensions.Execute[TState,TResult]

    · at Microsoft.EntityFrameworkCore.RelationalDatabaseFacadeExtensions.BeginTransaction

    · at Abp.EntityFrameworkCore.Uow.DbContextEfCoreTransactionStrategy.CreateDbContext[TDbContext]

    · at Abp.EntityFrameworkCore.Uow.EfCoreUnitOfWork.GetOrCreateDbContext[TDbContext]

    · at Abp.EntityFrameworkCore.Uow.UnitOfWorkExtensions.GetDbContext[TDbContext]

    · at CloudCafe.Migrations.Seed.SeedHelper.WithDbContext[TDbContext]

    · at CloudCafe.Migrations.Seed.SeedHelper.SeedHostDb

    · at CloudCafe.EntityFrameworkCore.CloudCafeEntityFrameworkCoreModule.PostInitialize

    · at Abp.Modules.AbpModuleManager.<>c.<StartModules>b__15_2

    · at System.Collections.Generic.List1.ForEach

    · at Abp.Modules.AbpModuleManager.StartModules

    · at Abp.AbpBootstrapper.Initialize

    · at Abp.AspNetCore.AbpApplicationBuilderExtensions.InitializeAbp

    · at Abp.AspNetCore.AbpApplicationBuilderExtensions.UseAbp

    · at CloudCafe.Web.Startup.Startup.Configure

    · at System.RuntimeMethodHandle.InvokeMethod

    · at System.Reflection.RuntimeMethodInfo.Invoke

    · at Microsoft.AspNetCore.Hosting.ConfigureBuilder.Invoke

    · at Microsoft.AspNetCore

  • User Avatar
    0
    MarkEaston created

    For some reason the website just keeps going to the Error page. Why? Why does it work perfectly locally,

    I also have a support request open with Microsoft. They are saying it is an Application Error.

  • User Avatar
    0
    MarkEaston created

    This is what Microsoft said ....

    Hello Mark, I hope you are fine,

    Thank you for contacting Microsoft Support, my name is Isidro Hernandez and I will be your Microsoft Azure Software Support Engineer, from the App Service team who will be working with you on this service request.

    Please reach me using the contact information listed below on my signature, referencing the service request number [120120726005246 - Its not receiving any requests]

    From the case description I understand that you are not receiving any request from the app service cc-api-svc-p-aue. I have monitored the app service, below my findings:

    On the app service we were able to find 500 errors, this server errors belong to the application level and are related to the application code.

    Please find below the exceptions we captured: Exception

    · at Microsoft.Data.SqlClient.SqlConnectionString..ctor

    · at Microsoft.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions

    · at Microsoft.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup

    · at Microsoft.Data.SqlClient.SqlConnection.ConnectionString_Set

    · at Microsoft.Data.SqlClient.SqlConnection.set_ConnectionString

    · at Microsoft.Data.SqlClient.SqlConnection..ctor

    · at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerConnection.CreateDbConnection

    · at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.get_DbConnection

    · at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.Open

    · at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.BeginTransaction

    · at Microsoft.EntityFrameworkCore.RelationalDatabaseFacadeExtensions.<>c__DisplayClass26_0.<BeginTransaction>b__0

    · at Microsoft.EntityFrameworkCore.ExecutionStrategyExtensions.<>c__DisplayClass12_02.<Execute>b__0

    · at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.Execute[TState,TResult]

    · at Microsoft.EntityFrameworkCore.ExecutionStrategyExtensions.Execute[TState,TResult]

    · at Microsoft.EntityFrameworkCore.ExecutionStrategyExtensions.Execute[TState,TResult]

    · at Microsoft.EntityFrameworkCore.RelationalDatabaseFacadeExtensions.BeginTransaction

    · at Abp.EntityFrameworkCore.Uow.DbContextEfCoreTransactionStrategy.CreateDbContext[TDbContext]

    · at Abp.EntityFrameworkCore.Uow.EfCoreUnitOfWork.GetOrCreateDbContext[TDbContext]

    · at Abp.EntityFrameworkCore.Uow.UnitOfWorkExtensions.GetDbContext[TDbContext]

    · at CloudCafe.Migrations.Seed.SeedHelper.WithDbContext[TDbContext]

    · at CloudCafe.Migrations.Seed.SeedHelper.SeedHostDb

    · at CloudCafe.EntityFrameworkCore.CloudCafeEntityFrameworkCoreModule.PostInitialize

    · at Abp.Modules.AbpModuleManager.<>c.<StartModules>b__15_2

    · at System.Collections.Generic.List1.ForEach

    · at Abp.Modules.AbpModuleManager.StartModules

    · at Abp.AbpBootstrapper.Initialize

    · at Abp.AspNetCore.AbpApplicationBuilderExtensions.InitializeAbp

    · at Abp.AspNetCore.AbpApplicationBuilderExtensions.UseAbp

    · at CloudCafe.Web.Startup.Startup.Configure

    · at System.RuntimeMethodHandle.InvokeMethod

    · at System.Reflection.RuntimeMethodInfo.Invoke

    · at Microsoft.AspNetCore.Hosting.ConfigureBuilder.Invoke

    · at Microsoft.AspNetCore

    If you have additional concerns, please let me know. We will be more than happy to help.

    Looking forward to your response,

    Best Regards, Isidro M Hernandez | Support Engineer | Azure Support

    Email: : : [email protected] | Manager: [email protected]

    Working hours: 08:00 AM – 05:00 PM CST | Local Time

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @MarkEaston

    I assume you have deployed to your Host project and Angular project under the same website. If so,

    1. Do you have a web.config in your deployed website's root folder ? And, does it have configurations simialr to this web.config
    2. Is your database created properly ? Could oyu check its tables ?

    If you can't figure it out, could you share the generated Log file with us ?

    Thanks,

  • User Avatar
    0
    MarkEaston created

    No I have not deployed then under the same website. I cannot see that web.config above (This site can’t be reached). My database is created properly. I can connect to the database fromy my local instance (Visual Studio) perfectly fine. In Azure it says the database connection is fine. All EF migrations are done.

    As per my other ASP.NET Zero project (www.enduroframe.net) I have the API deployed to an App Service and my Client Angular Website deployed to Azure Storage.

    When I go to https://cc-api-svc-p-aue.azurewebsites.net I get error code 404. I expect to see the tenancy logon. But this website works perfectly, locally, from Visual Studio. So why is it not working in Azure. The Microsoft Support people are telling me it is an application error.

    For my other website when I go to https://ef-hubapi-svc-t-aue.azurewebsites.net/ I get the tenancy logon. This is what I want for https://cc-api-svc-p-aue.azurewebsites.net. They are deployed in exactly the same way - with the same azure build pipelines.

    What "generated Log file" are yo talking about?

    Here is my web.config

    <?xml version="1.0" encoding="utf-8"?> <configuration> <system.web> <!-- 200 MB in kilobytes --> <httpRuntime maxRequestLength="200000" executionTimeout="7200" /> </system.web> <system.webServer> <handlers> <add name="aspNetCore" path="" verb="" modules="AspNetCoreModuleV2" resourceType="Unspecified" /> </handlers> <aspNetCore processPath="dotnet" arguments=".\CloudCafe.Web.Host.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" startupTimeLimit="3600" requestTimeout="23:00:00" hostingModel="InProcess"> <environmentVariables> <environmentVariable name="COMPLUS_ForceENC" value="1" /> </environmentVariables> </aspNetCore> <httpProtocol> <customHeaders> <remove name="X-Powered-By" /> </customHeaders> </httpProtocol> <security> <requestFiltering> <!-- 200 MB in bytes --> <requestLimits maxAllowedContentLength="209715200" /> </requestFiltering> </security> </system.webServer> </configuration>`

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    When I go to https://cc-api-svc-p-aue.azurewebsites.net/ui/login I can see the login page. So, it seems like your Homecontroller is not redirecting to ui/login page. You can change this on Azure side or in HomeController.

    I think the difference here is the environment. In development environment, your app redirects correctly but in production it doesn't. To fix this, you can modify HomeController's Index action and re-deploy.

  • User Avatar
    0
    MarkEaston created

    Ahh - you are right! Many thanks. I have fixed it now,

    I see in asp.net zero you have this:

        public IActionResult Index()
        {
            if (_webHostEnvironment.IsDevelopment())
            {
                return RedirectToAction("Index", "Ui");
            }
    
            return Redirect("/index.html");
        }
        
    

    Considering there is no index.html - why do you have this for production?

    In my webapp that works it is just:

         public IActionResult Index()
        {
             return RedirectToAction("Index", "Ui");
        }
    
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @MarkEaston

    This was designed for hosting Angular application and ASP.NET Core application under the same website. But, it seems like this causes a problem when hosting the apps separately. We will make enhancements on this.

    Thanks,