ASP.net web service on server sometimes doesn't load - asp.net

We have an ASP.net web service (.asmx) up on our server that one of our clients uses to get data from us.
They've been complaining about timeout issues occurring now and then. I decided to check out my code to see if anything could be causing the issue.
I went to our .asmx url using my internet explorer and saw that it just kept loading. This is the second time that I've noticed this happen. I just can't connect to the .asmx page. I get no error message, just keeps loading.
Now obviously, this would cause timeout errors for their client program as the service is unreachable. Any idea why this could be happening??
Also, where are the asp.net error logs usually stored on the server??? Is it in the same directory as the .asmx?? And do these error logs get generated automatically or do I have to put something in my code??
EDIT: Forgot to mention that the server where my web service resides is a Linux based server. I had to use MonoDevelop to package it for such.

Look at the application event viewer on the server. If any errors are occuring at the service level, you'll see them posted there. Timeout processes can be tricky to debug. If there are server resources that are being vied for by other application pools, this application might be getting the shaft. I would look at process usage of memory and cpu at the server first. If all looks well there, check into IIS and see what other applications reside with your service. If it is all good there, then I would look into your code for long running possibilities.

Related

Client app able to call API Locally but unable to do it in IIS

I have an application that his a .Net Core API.
Everything works locally, and by that means,
Client App --> hits an .Net Core API successfully.
Howevever we have pushed the app to IIS Server, and we are not able to successfuly hit the API.
I know this is extremely vague, but what is something that I should be looking at to diagnose address this. I pulled the code from the published branch, and it works like a charm on local, but does not work on Server.
I do not get any Server Side exceptions.
Is there network connectivity? Log into the server and open a browser and put in the URL to the API. Any HTTP error is good. It means you can reach the API. If it times out, that's bad and that's your problem.
How do you know there are no exceptions? Are you logging all exceptions? Are you sure no exceptions are hidden in try blocks that end up ignoring the exception?
Assuming it's a Windows server, check the Event Viewer for warnings or errors.

500 internal server error in asp.net website

I have two ASP.NET websites hosted on a server and connecting to the SQL database on on different server.
One of the website throwing 500 internal server errors (as custom error mode on in production). I am not sure what is causing these errors. And these errors are random, so I am not able replicate on dev environment. Both website having almost similar functionality but I am facing these errors only in one website. Recently there so many time out errors. So I asked the system admins to check the event log then they said lot of windows updates are pending, so they ran patch and rebooted both application and database servers.
After that I am getting 500 internal errors while going from login to default page in the website but I am sure there nothing wrong with code and these errors not caught in the application_error event in the global ascx file.
Any insights on how to troubleshoot this issue further?
Error 500 is very generic error. AFAIK when it happens an application pool of the application is 'killed'. It can be caused for instance by infinite recurrence (stack overflow).
To be honest it's impossible to tell you why this error occurs on your environment, but my advice for you is following: configure some logging system, there's a chance that it will log what causes an error before application pool will 'die'.
I strongly recommend ELMAH. It's a great tool and very easy to configure. If it won't help you should implement writing log messages in some important places of your application so you can target what module/class/method causes problem.
Here you can find a bunch of information about ELMAH:
https://www.stormconsultancy.co.uk/blog/development/tools-plugins/getting-started-with-elmah-asp-net-error-logging-and-reporting/
http://www.asp.net/web-forms/overview/older-versions-getting-started/deploying-web-site-projects/logging-error-details-with-elmah-cs
https://dillieodigital.wordpress.com/2011/03/30/elmah-a-quick-start-tutorial-and-guide/

ASP.Net Server Debugging

I am having a problem with my application. The application works perfect on my development machine. It fails, without any errors on the live server. The page loads, but the code doesn't execute apparently.
I have been stuck on this for a while because I can't figure out how to get any information on the problem. There are no errors, so my custom errors settings in web.config are not helping.
I looked around online and I heard there was some remote debugging tool. The article was from .Net 1.0. I tried to follow it, but its not going to work because I am using a shared server. I do not have permissions to start the remote debugger on the server side.
I tried creating some output text files with variable contents, but the files are not being created either. They are created on my development machine, but never show up on the server, again with no error.
I have no idea how I'm supposed to figure out what is going on, because I'm not able to step through the code once it's on the live server.
Is there anyway to step through, or debug the code once I've published it? If I spent the extra money on a VPS, would that allow me to debug on the server side? I'm assuming I could just install Visual Studio on the VPS and step through the program. I've never used a VPS before.
Unless you do something very special in your code, it is unlikely that it behaves differently on your server compared to your workstation.
It is more likely that the configuration on the server is not correct.
You are saying your
code doesn't execute
How do you know that? You should first confirm that your code is actually executing.
you are also saying:
it is now directing me to a page that says "Directory Not Found"
a web server it never looking for directories, it is looking for resources, check your iis http logs what substatus codes are you getting?, enable Failed Request Tracing and review the logs.
Using Process Monitor can also help determine what the web server is doing.
Start with a very simple page and see whether that executes fine.
What I'm saying is, first debug/fix the execution environment before trying to debug your code.
You would never install Visual Studio on a server, the default installation of a Windows Server doesn't even allow you to install it. Instead you can use remote debugging components on the server and use your local Visual Studio to debug remotely.

Mixing .NET versions between website and virtual directories and the "server application unavailable" error Message

Backstory
Last month our development team created a new asp.net 3.5 application to place out on our production website. Once we had the work completed, we requested from the group that manages are server to copy the app out to our production site, and configure the virtual directory as a new application.
On 12/27/2010, two public 'Gineau Pigs' were selected to use the app, and it worked great.
On 12/30/2010, We received notification by internal staff, that when that staff member tried to access the application (this was the Business Process Owner) they recieved the 'Server Application Unavailable' message.
When I called the group that does our server support, I was told that it probably failed, because I didn't close the connections in my code. However, the same group went in and then created a separate app pool for this Extension Request application. It has had no issues since.
I did a little googling, since I do not like being blamed for things. I found that the 'Server Application Unavailable' message will also appear when you have multiple applications using different frameworks and you do not put them in different application pools.
Technical Details - Tree of our website structure
Main Website <-- ASP Classic
+-Virtual Directory(ExtensionRequest) <-- ASP 3.5
From our server support group:
'Reviewed server logs and website setup in IIS. Had to reset the application pool as it was not working properly. This corrected the website and it is now back online. We went ahead and created a application pool for the extension web so it is isolated from the main site pool. In the past we have seen other application do this when there is a connection being left open and the pool fills up. Would recommend reviewing site code to make sure no connections are being left open.'
The Real Question:
What really caused the failure? Isn't the connection being left open issue an ASP Classic issue? Wouldn't the ExtensionRequest application have to be used (more than twice) in the first place to have the connections left open? Is it more likely the failure is caused by them not bothering to setup the new Application in it's own App Pool in the first place?
Sorry for the long windedness
You'd really need to obtain and review the server's Application & System event and HTTPERR logs for the period the server was reporting these errors.
Without these it'd be hard speculate what was the root cause of the problem.
Update:
OP incorrectly tagged his question so this next section no longer applies. However I'll leave in place because I think the information is useful for those encountering these issues and perhaps thinking about migrating to IIS7.x.
You are correct that running two different .NET Framework's in the same application pool can cause these errors but that's something you'd tend to see on Windows 2003/IIS6, not Windows 2008/IIS7.
IIS7 uses a slightly different approach to specifying which .NET Framework version is loaded and it's determined by the Application pool's managedRunTimeVersion property. When requests are processed by IIS/ASP.NET the site's Handler Mapping's use a preCondition attribute to determine when to load the requisite handler (which is kind of like a script mapping in previous versions of IIS).
This mechanism prevents the incorrect runtime version being loaded into the application pool's worker process.
So if an application pool is configured to run .NET Framework version v4.0 only that version will load, even if your application is built against v2.0.
There's a great article on how this works here:
Achtung! IIS7 Preconditions
The section on Handlers about half way through explains why the dangers of accidentally loading the wrong .NET version into a pool are mitigated by the preCondition feature.
A Server Application Unavailable error usually means something catastrophic has happened (like loading the wrong ASP.NET version's ISAPI filter into an already running worker process).
Not closing SQL connections is unlikely to cause this type of serious error. You'd more than likely be seeing a yellow screen of death runtime errors if that were the case. Running out of SQL connections usually doesn't bend ASP.NET so out of shape that the whole service tops itself.
My prime suspect would be a permissions problem where the application pool identity was unable to correctly access the application folders. But it's just a hunch.
Again, what you need to do is get the Application & System event logs and the HTTPERR logs (they reside in %systemroot%\System32\LogFiles\HTTPERR. That will contain clues and facts about what went wrong.
Update 2:
On Windows 2003/IIS6, if you have two applications running different ASP.NET versions that reside in the same pool you will get this error. In my experience (I work for a web hoster) it is the primary cause of this infamous error page:
There's also a tell-tale event logged to the Application Event log:
Event Type: Error
Event Source: ASP.NET 2.0.50727.0
Event Category: None
Event ID: 1062
Date: 12/01/2011
Time: 12:31:43
User: N/A
Computer: KK-DEBUG
Description:
It is not possible to run two different versions of ASP.NET in the same
IIS process. Please use the IIS Administration Tool to reconfigure your
server to run the application in a separate process.
Whilst your root application may not be written in ASP.NET it's likely that something has triggered loading of a different version of the framework into your site's application pool.
there's a rogue web.config in the root...this will trigger ASP.NET to load
there's a wildcard mapping to ASP.NET 1.1 in the site script maps (less likely, but possible)
I'm inclined to think that your new application most certainly ended up in a pool where other sites or applications were running a different framework version. The only way to really find out is to obtain the Application event logs and look for the event shown above.
It's hard to tell; there could be many causes (too many resources used, calling outside of .NET caused something to crash, etc). I would look in the Event log and see if you can find something there.
If you're running different versions of .NET you definitely want separate pools. If you have the option, I would recommend separate pools for each application (even if in the same .NET version).
As far as "closing the connection" (I assume you mean the connection to the database). If you're creating "low level" connections (i.e. SqlConnection, SqlCommand) then make sure you're wrapping them in a "using" statement, otherwise your connection pool can fill up. In my experience though, you should receive regular .NET errors in this case. If you're using an ORM this shouldn't be an issue.
Edit:
If you can't find anything useful in the Event Log, you could try this: http://learn.iis.net/page.aspx/266/troubleshooting-failed-requests-using-tracing-in-iis-7/

Very weird IIS6 asp.net website behaviour

I have a weird issue with my website. This is asp.net(.net 3.5) website hosted on a dedicated server IIS6.
Recently I got a strange behavior, the website hangs and just doesn’t reply unless I go to iis and restart either app pool or whole IIS - BUT what is the most strange thing is that in case I go to remote desktop of the server and try to access it locally it DOES work just fine.
I read couple threads about deadlocking and hanging because of memory leaks and non closed sql connections BUT why it still does work from the local?
In case there is something wrong with the code – why does it still work from locally?
In case there is some issues on the hosting side (like firewall issues) then why does iisreset help?
Any thoughts would be appreciated. Thank you!
We've just run into this problem, and we have a solution. IIS has two thread pools to handle requests. One thread pool is used for external requests. Another pool is used for local requests. Our problem was caused by a deadlock in backend code. Once the deadlock occurred, all external requests were queued but not serviced because all of the servicing threads were in use. Opening the website from the web server uses the other thread pool, so the requests are serviced. We were absolutley positive it was a network issue, but WinDbg proved otherwise.
See here for more information:
MSDN blog entry about IIS and threads
minLocalRequestFreeThreads
(Also, search for minFreeThreads to see the non-local request thread pools.)
Good luck!
Are you sure that the website hangs for all external users, so that it's not just one single user?
The IIS only runs one page at a time for each user, so if one request is caught in an eternal loop, that single user will experience that the server has stopped completely as no pages at all work until that page times out. The server will still work as usual for other users.
You can test this by using a different browser, or starting a new instance of the same browser (possible with IE, not with Firefox).
Hmm not enough info to really give you an answer, but I would look at your firewall first if it responds locally from the server. Do you have another server behind the FW like a SQL server? Try browsing from that as it will show you where the problem is.
My though would be a badly configured load balancer.

Resources