Hi,
Have a working CRUD application razor pages using .net core accessing a remote database when run on my pc works o.k.
However, after publishing this to web server shows error connecting to database with '' - something wrong with connection but not sure how to fix.
Steps in solution
startup.cs has
services.AddDbContext<RazorPagesMultipleContext>(options =>
// options.UseSqlServer(Configuration.GetConnectionString("RazorPagesMultipleContext")));
options.UseOracle(Configuration.GetConnectionString("RazorPagesMultipleContext")));
razorpagesmultipecontext has
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseOracle(@"User Id = <uname>; Password = <pwd>; Data Source = <SID>.WORLD", opt => opt.UseOracleSQLCompatibility("11"));
}
and works fine when run on my own pc.
Have published the solution and copied across to web server but get message
Error.
An error occurred while processing your request.
Request ID: 0HLME1V180M3A:00000001
Development Mode
Swapping to Development environment will display more detailed information about the error that occurred.
Development environment should not be enabled in deployed applications, as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the ASPNETCORE_ENVIRONMENT environment variable to Development, and restarting the application.
tried amending web.config to set to Development but then get
500 - Internal server error.
<aspNetCore processPath="dotnet" arguments=".\RazorPagesMultiple.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout"
<environmentVariables>
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
</environmentVariables>
/>
Had a look at the stdout and get below.
Hosting environment: Production
Content root path: D:\netcorepublished
Now listening on: http://127.0.0.1:12539
Application started. Press Ctrl+C to shut down.
warn: Microsoft.AspNetCore.HttpsPolicy.HttpsRedirectionMiddleware[3]
Failed to determine the https port for redirect.
fail: Microsoft.EntityFrameworkCore.Database.Connection[20004]
An error occurred using the connection to database '' on server '<SID>.WORLD'.
Oracle.ManagedDataAccess.Client.OracleException (0x80004005): Connection request timed out
at OracleInternal.ConnectionPool.PoolManager`3.Get(ConnectionString csWithDiffOrNewPwd, Boolean bGetForApp, OracleConnection connRefForCriteria, String affinityInstanceName, Boolean bForceMatch)
at OracleInternal.ConnectionPool.OraclePoolManager.Get(ConnectionString csWithNewPassword, Boolean bGetForApp, OracleConnection connRefForCriteria, String affinityInstanceName, Boolean bForceMatch)
at OracleInternal.ConnectionPool.OracleConnectionDispenser`3.Get(ConnectionString cs, PM conPM, ConnectionString pmCS, SecureString securedPassword, SecureString securedProxyPassword, OracleConnection connRefForCriteria)
at Oracle.ManagedDataAccess.Client.OracleConnection.Open()
at System.Data.Common.DbConnection.OpenAsync(CancellationToken cancellationToken)
Have below in appsettings.json and tried also putting below
Tried 1
{
"Logging": {
"LogLevel": {
"Default": "Warning"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"RazorPagesMultipleContext";
}
}
Tried 2
"RazorPagesMultipleContext": "User Id=dw;Password=m3l0n5;Data Source=(<SID>.WORLD, opt => opt.UseOracleSQLCompatibility("11"));"
{
"Logging": {
"LogLevel": {
"Default": "Warning"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"RazorPagesMultipleContext": "Data Source=(DESCRIPTION=(ADDRESS=(COMMUNITY=<SID>.WORLD)(HOST=<server>)(PORT=1521))(CONNECT_DATA=(SID=<SID>)(GLOBAL_NAME=<SID>.WORLD)));User Id=<uname>;Password=<pwd>;"
}
}
and even commenting it out altogether and without an appsettings.json file as would have thought would pick up connection from code itself.
any thoughts on why not connecting - server has other .net applications whci can see the dataqbase.
when set ASPNETCORE_ENVIRONMENT at server level display on screen below -
Annotations:
Oracle:ValueGenerationStrategy: IdentityColumn
ProductVersion: 2.1.4-rtm-31024
Relational:MaxIdentifierLength: 128
info: Microsoft.EntityFrameworkCore.Infrastructure[10403]
Entity Framework Core 2.1.4-rtm-31024 initialized 'RazorPagesMultipleContext' using provider 'Oracle.EntityFrameworkCore' with options: OracleSQLCompatibility=11
fail: Microsoft.EntityFrameworkCore.Database.Connection[20004]
An error occurred using the connection to database '' on server '<SID>.WORLD'.
Oracle.ManagedDataAccess.Client.OracleException (0x80004005): Connection request timed out