WebAPI not writing to Trace.axd - asp.net-web-api

I've got a WebAPI application (using RC), and I'm trying to write messages to the application trace. I tried following the tutorial here, which has me implementing ITraceWriter, and enabling it in Global.asax.
I did that, and when debugging, it hits breakpoints in my SimpleTracer class, but when I visit Trace.axd, my trace information section is blank. I also tried to write to the trace directly with System.Diagnostics.Trace.WriteLine("Hello, world!"); and it is still blank.
What could I be missing? Does the RC version perhaps not have this functionality?

Although not a direct answer to your question have you looked at using the official NuGet package (here) which Enables ASP.NET Web API tracing using System.Diagnostics? This was released as alpha back in Aug 2012 (sometime after the blog you followed to create your example) and is now at RC level.
There are instructions on how to install it here. Which may also assist you with your custom one should you wish to carry on with it.

Related

How to run Microsoft Teams sample app in debug mode

I am using this app https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/tab-personal-sso-quickstart/csharp_dotnetcore
It works fine.
I wish to extend the functionality - specifically in auth.js - so I need to be able to run it in Debug mode.
I have tried for some time but have no success getting a breakpoint hit. I use the instructions at https://devblogs.microsoft.com/microsoft365dev/debugging-microsoft-teams-app-locally-with-teams-toolkit as guidance but have no success. (In particular I don't have 'Debug (Chrome)' or same for Edge available as a config in VS Code.
Can anyone point to guidance on this please or perhaps advise if I need a specific launch.json config
Thanks
Update – the Teams sample code I was using comes from https://github.com/OfficeDev/Microsoft-Teams-Samples
They run fine but I had no success getting them to debug. Any search for ‘Teams samples’ is going to find those first!
The repo linked from the ‘Samples’ button of the VS Code Teams Toolkit is at https://github.com/OfficeDev/TeamsFx-Samples and works as the article above describes.
As for why there are 2 sets of official samples, not cross referenced … go figure.
Hope that helps someone.

ASP .NET 5 WEB API creating help page

I just got started working on ASP.NET 5. I want to have a help page for my methods, I have seen few examples for creating help pages but most of them are MVC specific. I have gone through Microsoft.AspNet.WebApi.HelpPage package, it creates an Area for help page but I am not using MVC pattern.
Any suggestions how can I create help page other than this area approach?
I would suggest looking at Swagger and SwaggerUI. Swagger is an open standard, using JSON to document an API, used by the likes of PayPal and Microsoft (check out Logic apps in the azure portal).
There are some open source implementations for .Net (both of which I have used), which will self document your API, just by adding the NuGet packages to your project and a little bit of configuration:
https://github.com/domaindrivendev/Swashbuckle
https://github.com/domaindrivendev/Ahoy
Swashbuckle is the original project and Ahoy is the new version targeting ASPNET5. When downloading the package from NuGet you will still get Swashbuckle, just make sure you tick "include pre-release", and if you need any documentation look at the original GitHub project.
SwaggerUI (which is also included in Swashbuckle) adds an interface which you can use to navigate and test your API, by default this is available from "/swagger/ui" when your project is running.
Here is a sample repo in GitHub I put together showing how it can be used: https://github.com/mattridgway/ASPNET5-SwaggerUI

How to tell what is trying to load a specific assembly?

I have an MVC project that is failing once I deploy to Azure because it's trying to load an MVC4 assembly. I have upgraded the project to MVC5.
I am trying to find what has a dependency on the MVC4 dll.
How would I go about finding what is causing it to try and load the MVC4 dll?
Fusion logs are the way to go for something like this. Here's a handy little blog that sums up the registry changes you need to add to capture the log on your instance. Add this as part of a startup task. In this post he also gives the location to the log viewer (on your local dev machine) that you can use to view the log.
Is this the same issue that you asked a week ago and received an answer for? https://stackoverflow.com/questions/19716911/web-role-fails-on-azure-after-upgrading-from-mvc4-to-mvc5/19733292#19733292
Rick's Fusion Logs option is also a great way to determine this.

Troubleshooting AppHarbor's "LogEntries" Add-On

I've configured everything with LogEntries and log4net according to this article: https://logentries.com/doc/appharbor/
However, in my LogEntries panel, I only see events from the IIS log - nothing that I'm logging from my application using log4net. Can someone suggest troubleshooting steps so my custom events will start showing up?
Few things to check here, what version of the logentries.log4net nuget did you install? You can check this if you're using VS in your Nuget package manager. (Note that there's only v2.4.0) But there is an old library upto v2.3.9 called le_log4net which is deprecated, I have to change the title on the package. Secondly, if you paste the content of your web/app.config, only important parts are the log4net block and you appSettings. Lastly, be sure to place the following in your AssemblyInfo.cs as its sometimes overlooked.
[assembly: log4net.Config.XmlConfigurator(ConfigFile="Web.config", Watch = true)]
You can email me at mark#logentries.com or use our in-app support (I'm with Logentries and wrote the .NET libs.) as it may be quicker than debugging on here. Although its no harm doing it here so as to keep the solution public.

Custom Statistics in TeamCity 6.0

I am trying to follow this writeup (http://pwigle.wordpress.com/2009/12/11/code-metrics-statistics-with-team-city/) to add code statistics to my TeamCity 6.0 Ci server. I have gotten everything to work as described in the writeup except the last part where the results of the SourceMonitor are displayed in the statistics page. Is there something different that I need to do in TeamCity 6.0 to get this to work?
FYI you have to edit (TeamCity path).BuildServer\config\main-config in 6.0 instead of (TeamCity path).BuildServer\config(project name)\plugin-settings.xml. The plugin-settings.xml file is still present in 6.0 but doesn’t appear to do anything anymore. After that all works as detailed in the write up I posted before.

Resources