My Blazor server app behaves different on two windows Server 2019 - https

I have a blazor server application developed and published with .Net 6 that runs on a windows server 2019 and uses a ASP.Net 4.8 web service. One of mothods of web service takes approximatly 45 seconds to be executed. During calling this web method I encounter with an exception as follows:
---> System.Net.Http.HttpRequestException: An error occurred while sending the request.
---> System.IO.IOException: Unable to read data from the transport connection: Eine vorhandene Verbindung wurde vom Remotehost geschlossen..
In this case there isn't any error in web service and the exception occures because of long response time of web method.
On the other hand I Have a test server that have exactly the same hardware characteristics as the last one. It's OS is also windows server 2019, and the only difference between two servers is that on test server, I have installed Visual Studio 2019 because of testing purposes. On this server, the blazor app calls the web method without any problem, although it take also a long time to return.
I don't know why this error occurs in the first case. Are there any dependencies I need to provid? I suspect it is due to installed VS2019 that there is no error on the test server.
How can I check, what dependencies I need to install on product server to avoid this exception?

Related

.NET 6 webapp returns 503 error on random intervals

I published a simple .NET 6.0 web app with user authentication on my IIS 10.0 web server hosted on Azure.
The application read and write data from a SQL Server 2017 database hosted on another machine on the same virtual network of the web server.
Everything works fine but after a while, even though nobody is using the app, it stop working and send Http Error 503 Service Unavailable and I have to restart it every time from the application pool.
I enabled tracing on the event log, but I don't receive any message explaining this.
These are the application settings:
IIS application settings
I tried to follow these advices but none of them worked:
IIS HTTP Error 503. The service is unavailable
503 “Service Unavailable” error for all apps after installing .NET Core 2.2 Runtime & Hosting Bundle for Windows
.Net core Service Unavailable after Publish to IIS
On the same web server I have other applications but this problem appears only on this one. None of the other apps is using .NET 6, most use .NET Framework 4.7/4.8 and another couple .NET Core 3.1.
I also tried to publish the application on Azure WebApp service and it has the same problem.
1. If you're deploying on IIS, we can install DebugDiag Tools and then use the DebugDiag collection to crawl the dump logs.
2. If you are using the azure app service, it is recommended to get dump in the azure portal.
My Suggestion
Enable Failed Request Tracing, and find which request will cause the Http 503.
Maybe this 503 is not a problem with the code, and it is possible to find some useful information in the log.
Check the EventViewer, try to find the useful info about the application.
Download the DebugDiag Tools, use debugdiag collection to collect the dump file when the issue occured, and use the debugdiag analysis to analyze the dump file and check the stacktrace.
My suggestion can't tell you the root cause directly, but it will help you to find it. You are also welcome to update the useful stacktrace information in the future, and there will be more people to help you.
I'm currently having the issue but using MySQL on a remote server.
Azure WebApp, Azure VM (IIS 10) and AWS EC2.
Http Error 503 Service Unavailable when the database connection timesout or fails to connect and the AppPool failed to restart.
No crashes when debugging in VS via console app.
I changed the hosting model to out-of-process and this solved the issue.
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" hostingModel="outofprocess">

WSDL Authentication Error Appearing on web reference connection

When adding a web reference to a visual studio 2019 web service project I am getting the following errors:
" - The underlying connection was closed: An unexpected error occurred on a send.
Authentication failed because the remote party has closed the transport stream."
and
"The custom tool 'MSDiscoCodeGenerator' failed. Unable to import binding 'Soap11' from namespace http*****"
The server offer three webservices, first web service worked perfectly no issues. The second brings up these errors.
I suppose my question is, seeing as this looks like configuration on the third parties end, is this a visual studio error?
All WSDL offerings from the server work perfectly in the browser and in SOAPUI

SQL Server 2017 Connections working in ASP.NET C# Web projects, but not in Windows projects, in Visual Studio 2019

Using the basic SqlConnection code below, I have discovered that, at my workstation, I am unable to connect to our Sql Server 2017 deployment via ASP.NET C# code in any given type of Windows-based project, such as Winforms (.NET Framework or Core) or Console apps. However, this code will run without incident in any Web-based project, such as Web Forms or MVC, either using .NET Framework or Core.
protected void testConnection()
{
string con = "Server=MySqlServer;database=MyDatabase;Integrated Security=true";
using (SqlConnection cnn = new SqlConnection(con))
{
cnn.Open();
cnn.Close();
}
}
In a web project, this code runs. In a Windows project, I get this error:
System.Data.SqlClient.SqlException: 'A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)'
In investigating this problem, I have tried the following:
Explicitly declaring the domain on which my SQL server is found (eg. MySqlServer.domain.com). No good.
Explicitly declaring the SQL Server port number, according to the example shown on connectionstrings.com (eg. MySqlServer, 1433). We do use the standard port number, for the record. No good.
Changing the protection level of the test method (protected/private/public). No good.
Connecting to the SQL Server in PowerShell. This connection worked.
Pinging in the SQL Server in a command prompt. The server responded in 1ms consistently.
I have asked other users on this network to test this code in a Winforms project on their workstations. No one is able to reproduce my issue.
Consulted my sysadmin. He is so far not able to find any reason why I should be having this issue.
The only difference I have noticed in all of this is that, when I declare the port number, the Inner Exception returned with the error reads "Win32Exception: A non-recoverable error occurred during a database lookup". Otherwise, it simply reads "Access is Denied."
All of this tells me that the issue is obviously something peculiar to my workstation, but I have no idea what, apart from some firewall or other local security setting that the sysadmin neglected to check. Has anyone encountered this problem?
My VS 2019 installation is only one revision out of date as of this writing, 16.8.3 as opposed to 16.8.4. I am able to connect to and run TSQL code on any database I care to via SSMS. We connect using Windows Authentication. According to the results of "select ##version", our version of SQL Server is 2017, 14.0.3356.20 (x64).
Any insight is appreciated.
We fixed it by forcing Named Pipes to be enabled in SQL Server, as opposed to using the default setting.

Visual studio debug access to external database

I have a question as to how the Visual Studio 2013 debug emulator for Web API works.
I had built a Web API project in Visual Studio 2013 to access a database on an external server. The code was built using VS2013's ASP.NET Web Application project template for a Web API application. Once built, running debug opened a browser window for localhost port 56618, which allowed access from Fiddler to test Http requests.
Once I had the project finished, I published it to a website using Web Deploy to IIS. However, whilst the page would open (now at localhost:9812), an http request would throw an Internal Server Error 500.
Perusing the IIS FailedReqLogFiles, I noticed that the reason that it was failing was that the database server was refusing access to '<Domain>\<machine-name>$'.
I added '<Domain>\<machine-name>$' as a valid login (windows authentication, as the connection string included "Integrated Security=true") on the sql instance with read and write privileges, and the problem was resolved.
The question is, why didn't the Visual Studio debug emulator have the same issue?
Because the emulator was running the website under the context of your own account (e.g. <Domain>\You). Your account had access to the database, so there was no issue.
When you published it to IIS, it started running under the context of a different account (<Domain>\Machine-Name - but there are other variants depending on how IIS is configured, and the version of IIS), which didn't have access to your database.

ASP.NET MVC3 webdeploy: database deployment on production

I am using webdeploy to deploy my web application to IIS. I followed Microsoft's 12 part tutorial for this. I successfully deployed it on my local IIS.
I have to now deploy this to production and I am following the same steps. I am connected to the remote machine via VP. Form VS2010 publish profile the connection to the server was successful. But when I enter the DB connection string as
"Data Source=xxxx\SQLExpress;Initial Catalog=SWSS;Integrated Security=True"
and try to preview the Database, I get the following error:
Web deployment task failed. ((4/1/2013 9:18:42 PM) An error occurred when the request was processed on the remote computer.)
(4/1/2013 9:18:42 PM) An error occurred when the request was processed on the remote computer.
Exception has been thrown by the target of an invocation.
Member 'ClassName' was not found.
The remote machine does not have TCP/IP enabled.
1. Is it safe to enable this in production machine?
2. If not, how to deploy DB, taking advantage of the dbdacfx?
Update 1:
Based on the comments below, I have changed my connection string as follows:
"Data Source=SWSS\SQLExpress;Initial Catalog=SWSS;User Id=xxxx;Password=xxxx;"
I created a sysadmin user in SQL server with SQL authentication rather than Windows authentication. Now the error is as follows:
Web deployment task failed. (Could not generate deployment script.
Unable to connect to target server.
Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_EXECUTING_METHOD.)
Update 2:
Using mixed mode authentication on SQL Server fixed my issue.

Resources