Base solution for your next web application
Open Closed

CalculateContentRootFolder Error after deployment #3013


User avatar
0
paradoxit created

When I call CalculateContentRootFolder in WebContentDirectoryFinder it works locally but when deployed to Azure I get the error System.ApplicationException: Could not find content root folder!

I make the call an AppService in the Application project if that helps.

Could you please advise how I resolve this? It appears the code is looking for a sln file which won't exist in the deployed version.


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

    Hi,

    This method is designed for development time usage, you should not use it for production. If you can explain your case, we can try to find anotner solution.

    Thanks.

  • User Avatar
    0
    shimulcse created

    I used this for getting SqlConnection to execute StoredProcedure.

    private readonly IConfigurationRoot _Configuration;
    
            public CargoReportAppService(ICargoHeldupLogRepository cargoHeldupLogRepository,
                ICargoReceivingInfoDetailRepository cargoReceivingInfoDetailRepository)
            {
                _CargoHeldupLogRepository = cargoHeldupLogRepository;
                _CargoReceivingInfoDetailRepository = cargoReceivingInfoDetailRepository;
                _Configuration = AppConfigurations.Get(WebContentDirectoryFinder.CalculateContentRootFolder(), addUserSecrets: true);
            }
    
    using (var dbConnection = new SqlConnection(configuration.GetConnectionString(SODMSConsts.ConnectionStringName)))
                    {
                        await dbConnection.OpenAsync();
                        cargoReceivingData = await dbConnection.QueryAsync<GetCargoReceivingReportOutput>("CargoReceivingReport",
                                            new
                                            {
                                                FromDate = input.FromDate.Date,
                                                ToDate = input.ToDate.Date,
                                                AccountId = (input.AccountId == 0 || input.AccountId == null) ? null : input.AccountId,
                                                DepotUnitId = (input.DepotUnitId == 0 || input.DepotUnitId == null) ? null : input.DepotUnitId
                                            },
                                            commandType: CommandType.StoredProcedure);
    
                    }
    

    This is working fine in locally but getting error in production. Kindly suggest me other way to do that.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @shimulcse,

    You can create a custom repository and execute your SP in that custom repository. <a class="postlink" href="https://aspnetboilerplate.com/Pages/Documents/Repositories#custom-repositories">https://aspnetboilerplate.com/Pages/Doc ... positories</a>