A weired error about HTTP 500 !

Alick Wang 266 Reputation points
2024-04-10T07:22:48.6266667+00:00

I created a web user asp.net 8.0 mvc without ef.

When I modify the stucture of oracle datebase table ,such as add a field ,then the web related to the table report a error about HTTP 500 . But after I restart the iis,it works well without doing anything else!

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,177 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 56,526 Reputation points
    2024-04-10T17:10:40.7133333+00:00

    As we can not see your code, we have no idea why it behaves this way. I’d assume you have some init code that needs to run on a schema change.

    0 comments No comments

  2. Alick Wang 266 Reputation points
    2024-04-11T08:51:09.7866667+00:00

    .net 8.0 with Dependency Injection

    In Program.cs

    builder.Services.AddScoped<DAL.Account.IAccount,DAL.Account.Account>();

    In Account.cs

    public class Account : IAccount

    {

    private readonly IOptions<DAL._DBConnStr> _dbconnStr;

    public Account(IOptions<DAL._DBConnStr> dbconnStr)

    {

    _dbconnStr = dbconnStr;

    }

    public DataTable GetRoles()

    {

    using (OracleConnection conn = new OracleConnection(_dbconnStr.Value.myConnectionString))

    {

    DataTable dt = new DataTable();

    OracleCommand selectCmd = new OracleCommand("select * from roles order by sortindex", conn);

    OracleDataAdapter da = new OracleDataAdapter();

    da.SelectCommand = selectCmd;

    da.Fill(dt);

    return dt;

    }

    }

    In AccountController

    IAccount AccountDA;

    public AccountController(IAccount accountDA)

    {

    AccountDA = accountDA;

    }

    public IActionResult Login(string ua)

    {

    DataTable dt = AccountDA.GetUserAccountByUser(ua);

    }