C# System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send

Setting the HttpWebRequest.KeepAlive to false didn’t work for me. Since I was accessing a HTTPS page I had to set the Service Point Security Protocol to Tls12. ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; Notice that there are other SecurityProtocolTypes: SecurityProtocolType.Ssl3 SecurityProtocolType.Tls SecurityProtocolType.Tls11 So if the Tls12 doesn’t work for you, try the three remaining options. Also notice you … Read more

The name ‘ViewBag’ does not exist in the current context

Sounds like you’re missing the following in the Web.Config in the views folder: /Views/Web.Config <?xml version=”1.0″?> <configuration> <system.web.webPages.razor> <host factoryType=”System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35″ /> <pages pageBaseType=”System.Web.Mvc.WebViewPage”> // <– this line and contents are important <namespaces> <add namespace=”System.Web.Mvc” /> <add namespace=”System.Web.Mvc.Ajax” /> <add namespace=”System.Web.Mvc.Html” /> <add namespace=”System.Web.Routing” /> </namespaces> </pages> </system.web.webPages.razor> Views typically derive from … Read more

Error message: (provider: Shared Memory Provider, error: 0 – No process is on the other end of the pipe.)

Typically, to troubleshoot this, you go to SQL Server Configuration Manager (SSCM) and: ensure Shared Memory protocol is enabled ensure Named Pipes protocol is enabled ensure TCP/IP is enabled, and is ahead of the Named Pipes in the settings Maybe it can help: Could not open a connection to SQL Server Note : If this … Read more

How do I determine if a port is open on a Windows server? [closed]

Assuming that it’s a TCP (rather than UDP) port that you’re trying to use: On the server itself, use netstat -an to check to see which ports are listening. From outside, just use telnet host port (or telnet host:port on Unix systems) to see if the connection is refused, accepted, or timeouts. On that latter … Read more

How do I measure execution time of a command on the Windows command line?

PowerShell has a cmdlet for this called Measure-Command. You’ll have to ensure that PowerShell is available on the machine that runs it. PS> Measure-Command { echo hi } Days : 0 Hours : 0 Minutes : 0 Seconds : 0 Milliseconds : 0 Ticks : 1318 TotalDays : 1.52546296296296E-09 TotalHours : 3.66111111111111E-08 TotalMinutes : 2.19666666666667E-06 … Read more