Log messages from Web API to console in .NET 4 and IIS6 - asp.net

Coming from Java servlet containers, I really find it annoying that the IIS server (I am stuck with IIS6 on Windows Server 2003) does not have a console output that can be used to log messages into.
Is there a way to do this? I'd like to debug a particularly specific hardware/software deploy configuration that doesn't make my RESTful service, written with WebAPIs in .NET 4, work properly.
I'm thinking if there is some way to write to an output buffer and then consume it by attaching to that particular stream from a cmd console window.
Thank you.

I ended up writing events in the Windows Event log. A crappy solution for a crappy way of doing stuff, if you ask me.

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.

Easier way? Azure Websites, Application logging asp.net

When I get a call there was an error in our web application when running on a windows server I would simply go to Windows Logs and scroll down the application logs and find the Warning. Easy to read and made it quick to solve the problem.
Now I'm testing out Azure Websites to run asp.net applications and i'm racking my brain trying to figure out how to have the same kind of quick error find a fix process.
Viewing the application logging in Azure's application diagnostics is utterly useless.
It would take me forever to dig through those logs. rewriting the application to handle errors differently is not an option for me.
So who else is having this problem? any solutions?
The easiest solution is to offload your error logs to a separate service like Raygun. This will result in a (small) monthly fee but is a 5 minute setup and you are good to go.
Otherwise you can go and use Log4net to log your error to the blob storage but then you will have to poll that one for your logs.
Try the Azure Website Log Browser site extension, you can install it from the new Azure Portal on your website (as a site extension) and it makes it easier to view all of your logs.
Read more about it here.

Shell.Invoke doesn't launch the powershell script in deployed asp.net web application

I wrote an asp.net web application, which launches a powershell script. The program ran without any issue when I debugged it in my development environment. After publishing and deploying the asp.net web application (by the way the target server is the same machine localhost), by clicking the button for launching the powershell script, nothing happened. It means the powershell script was not launched. I attached the debugger to the deployed asp.net and saw that the Shell.Invoke() was hit as before and the command was also correct. However Shell.Invoke() returned immediately and the powershell script was not launched. In my environment the powershell execution policy is RemoteSigned.
Since the program in the development environment works perfectly and in the deployed case also hits the same code, I don't think it has to do with the code but more with security, certification,...???
Has anyone experienced the same? If yes, please advise me what I should do.
I appreciate your help in advance.
Thx
Might have something to do with the application pool identity not having the right permissions:
You might want to run your PowerShell invocation from a system service with explicit permissions though. That will take a steeper curve though.

Run aspx file every hour

I have an aspx file on my windows 2012 server, I've come from Linux servers so i'm used to cron jobs. I googled and found a lot of talk of using the Task Scheduler, but all the documentation is on Microsoft's site and is completely impossible to understand for anyone that doesn't have a PhD in English.
Can anybody that has experience help me out?
I don't know if it's possible for you to do or not, but if you take the logic from your aspx page and turn it into a Web Service, you can create a simple console application (.exe) that executes your Web Service code. The task scheduler would call the executable instead of opening a browser.

How do I monitor ASP errors

I come from a mainly PHP background and make good use of the Apache error logs by using the command line. I've recently been handed a large ASP/ASP.NET project that I need to make changes to, where do I find the error logs on a Windows IIS setup so that I may troubleshoot some issues?
You haven't said which version of IIS you are using. In IIS 6, the HTTP error log is located in systemroot\System32\LogFiles\HTTPERR.
ASP.net itself won't produce any error logs unless it is configured to do so. There are many ways to do this for example with Log4net, Enterprise Library Logging Application Block, trace diagnostics or a roll your own approach.
Have a look in the web.config file and see if/how logging is configured for the application.

Resources