Category: SignalR

ElmahR – monitor errors in your app using a dashboard

If your unfamiliar with Elmah and/or ElmahR then please take a quick look here.

If you’re using Elmah but haven’t taken advantage of ElmahR then read on.

If you have one or more application(s) which currently use Elmah then you can very easily add in ElmahR which gives you a superb dashboard from where you can monitor either one or all of you applications which log errors.

The dashboard is basically one webpage which makes very nice use of SignalR to display information regarding errors thrown by your application(s), so if you deploy something and you monitor this page and see the error count for your application counting up quickly then you know you have a problem. You can use the dashboard to monitor a number of applications on different environments for example.


Existing/New Web Application

  • Either create a brand new test web application or you can use an existing web application – add ElmahR to this application using the Nuget package as below:-
    ElmahR
  • Ok now that we have added ElmahR to a web application we need to configure it accordingly, open up the web.config and look for the elmah section, should look something like this:-
  • elmah1

  • Important – The sourceId setting needs to match the sourceId setting in our dashboard application’s web.config

DashBoard

  • Now lets create our dashboard, so create a new MVC or Web application, then add the Nuget package as below:-
    ElamhrDash
  • Now we need to edit the dashboard’s web.config so that the sourceId’s match, shown below:-
    elmahr3

Testing ElmahR is working

  • Within your web application we want to test that ElmahR is set up and working correctly, to do this we need to have an error generated, so deliberately add an exception, such as a throw new NotImplementedException() or similar into an area you can test quickly (e.g. index actionresult within the home controller in MVC)
  • Run the dashboard application, which should look something like this:-

    elmahr5

  • Then run your web application and browse to the page which will generate an error so we can see if it logs as we expect.
  • If you have everything configured correctly then you will see the error count change in the dashboard application, like so:-
    elmahr6

TroubleShooting

  • If you don’t see your application logging errors on the dashboard it’s usually the sourceId element or the targetUrl element within your web.config

Hope you find this of use and start using ElmahR.

If you get stuck or something isn’t working add a comment.




AspConf – My Review

Last week we had AspConf – “aspConf is a virtual conference focused on one thing: showcasing the ASP.NET stack as the platform for great web applications.

Over 2 days they had 5 virtual rooms used to present lots of fascinating stuff on .Net, including talks about all manner of things in the Asp.Net world.

The sessions on both days covered topics such as, Async in .Net 4.5, Glimpse, TDD, Azure and Cloud Computing and lots lots more, you can read more about the sessions here.

Although it had some technical difficulties, due to its popularity I may add, the conference is an awesome way to learn for free – and free is always good. It’s a superb way to learn about content you havent had time to look at it, or new technologies you havent heard of. Hopefully next year they might try to use something different from livemeeting.

If you missed any of the session then fret not, most of them if not all of them were recorded and put up on Channel 9 here

I only managed to see sessions from day 2 so I am off to go watch more content on Channel 9 – a great resource for free learning.



Scott Hanselman’s Scotland Tour – Glasgow Talk

Scott Hanselman was touring Scotland and taking in some of our country as well as some talks in Edinburgh, Dundee, Aberdeen and finally Glasgow. You can read more about the event on his site Scott’s tour of Scotland. The following is my review of his talk in Glasgow which was on Friday 13th of July.

Scott was delivering his – One ASP.NET (super everything talk) covering almost everything going on that Microsoft are working on/have to offer for developers within Asp.Net

The talk covered the following areas – Visual Studio 2012, SignalR, WebAPI, Webform improvements, Azure and also what to look forward to when .Net 4.5 is released.

Visual Studio 2012

Visual Studio 2012 – Scott was kind enough to demo a build newer than the RC which had some unseen bits.

CSS improvements – Scott demoed some of the new features when you have a .css file open in the VS 2012 editor, actual colour pickers where you can choose the colour, including a droplet for choosing a colour out with Visual Studio which will be picked up when selected. Styles are also indented so for example you can have an .li tag and a .li a tag nicely formatted and indented below the .li tag.

Browse with option – you can now select from any browser which you have installed on your pc as well as iphone and ipad and this will display your website rendered in which ever browser you wish, you can also mark several of these as default, this means that when you run your site in VS 2012 and say you have selected FireFox, IE and Ipad as your default browsers the site will open up in all 3.

Javascript improvements – VS 2012 has much better intellisense and by this I mean true intellisense, if you define a new function within your javascript file or webpage and then call it elsewhere you’ll get full intellisense for the function your calling – impressive stuff indeed.

WebAPI – Scott demoed WebAPI as there were quite a few people myself included who hadn’t really looked into this as yet, it looks cool though and a lot easier than WCF, also if you’re using MVC seems very easy to pick up. Scott demoed just how easy it was to create a class and change the response from a method to return XML or JSON just by changing the content-type from within Fiddler, this means that you can have your methods returned using XML or JSON as well as other formats and then send this data off to whatever system requires data in whatever format it requires – nice!.

Find more info about WebAPI on the Asp.Net website here.

SignalR – and the SignalR demo Scott showed are both available on Nuget using the following command from the package manager console:-

SignalR

and the demo Stock Sample application

SignalR Demo Application

Azure – Scott talked about the hard work Scott Guthrie and his team had recently put into Azure and showed the latest release of Azure and it all looked pretty impressive stuff, you can create up to 10 websites and have them deployed and hosted on Azure for free. Also available is VM’s with different operating systems such as Windows Server and Linux.

Within a couple of minutes Scott had created a website and added it to Git and deployed to Azure, then made an update and deployed the change, he then rolled the deployment back to a previous version of the website all in seconds – cool stuff indeed.

Azure

You can get a free trial of Azure by following this link here.

.Net 4.5 – Scott talked about Tasks and the new asynchrony possibilites coming with it, showing some nice additions you can use to have truelly asynchronous code – you can read more on this on msdn blogs here.

Feedback on his Talk
Scott is obviously a great speaker and a funny guy too and the content of the talk was excellent, I like demos and the content he showed was pretty neat, VS 2012 looks very promising. I liked how he gives his opinion on things that aren’t the Microsoft opinion and will openly slate something he doesn’t like. The questions asked by the attendees were very good too and he covered a fair amount of stuff in the time given – hopefully he will return sometime in the future and I hope he and his dad enjoyed their tour of Scotland.

You can follow Scott Hanselman on Twitter here.

I know i missed some of the content out, forgot to take notes, if anyone wants to ask questions or comment on this post please by all means do – I’ll update this post If i remember anything I missed.




ElmahR – Elmah fused With SignalR

If your using Elmah then you’ll be familiar with most of this blog post, if not then don’t worry Elmah stands for Error Logging Modules and Handlers and is used to log unhandled exceptions to the file system, event log, databases or even have it email you the errors.

ElmahR was created by Roberto Vespa (@wasp_twit) and his blog on ElmahR can be found at:- Roberto’s blog

The basics – ElmahR uses Elmah and SignalR to create a dashboard page where you can monitor any unhandled exceptions in all of the applications you have running which use Elmah, that means if you have 5 websites in production you can have one web page monitor them all.

ElmahR Dashboard

To view an example dashboard running on app harbor.

ElmahR uses SignalR which again you can read more on Scott hanselman’s blog

Now lets see how we go about setting this up to work with a new MVC 3 project – the same steps apply to adding it to an existing web application.

  • Create a brand new web application, mvc or normal web app works fine.
  • Using Nuget add the following packages to your blank MVC solution, so add Elmah and JQuery.
  • Once both added follow the configurations steps here
  • You can install the Nuget Package:- ElmahRSource