I convert .NET apps with MySQL to SQL Server, before that working on hosted server after converting working from my local system successfully apps connecting to SQL Server, but same after publishing and on a live Windows Server with IIS, I’m getting this error:
No webpage was found for the web address:
http://scbkyc.airanlimited.in/
HTTP ERROR 404
Code:
builder.Services.AddDbContext<Context>(options =>
{
options.UseSqlServer(builder.Configuration["ConnectionStrings:DefaultConnection"],
ersion.AutoDetect(builder.Configuration["ConnectionStrings:LM"]),
MssqlOption =>
{
MssqlOption.EnableRetryOnFailure();TimeSpan.FromSeconds(6000), null);
}).EnableSensitiveDataLogging().UseLazyLoadingProxies();
}, contextLifetime: ServiceLifetime.Transient, optionsLifetime: ServiceLifetime.Transient);
This is working fine in Visual Studio 2022 on my local machine. I can properly connect and it works, but after publishing to the live system, I’m getting error HTTP 404.
2
Answers
Please alobrate step cmd aceess on server in cmd run actuall dll name not work run is not command or batch files
If you have access to the server Command Prompt, go to the folder of the app on your server and type in: run YourApp.dll ... obviously replace YourApp with the actual name of the dll of your app in that folder. If that works then you have an IIS misconfiguration... if it doesn't work, then it will show the actual error that is preventing your app from starting.
There are many possibilities for this issue, but I’m going to take a stab at it with what is arguably the most likely reason, and that is that you need to install the
.NET 6
Hosting Bundle on your server. You can find it here:https://dotnet.microsoft.com/en-us/download/dotnet/6.0
After installing it be sure to restart your server… then maybe it will work. If not you’ll need to keep digging, especially digging in your server logs and
Event Viewer
, to find out what the actual error is.If you have access to the server
Command Prompt
, go to the folder of the app on your server and type in:run YourApp.dll
… obviously replace YourApp with the actual name of the dll of your app in that folder. If that works then you have anIIS
misconfiguration… if it doesn’t work, then it will show the actual error that is preventing your app from starting.