• Using Elmah in your website

    by Venkata Koppaka | Dec 05, 2009

    Off late I have been using many of open-source projects in the websites that I am trying to build.

    Elmah is one among them  - Click Here to know more about Elmah.

    Here is my quick take on how to use Elmah in your website.

    NOTE: This demo application is built using .NET Framework 4.0 and Visual Studio 2010 Beta2.

    To start using Elmah in your website, include Elmah.dll in to your website. Go to the website right-click on the solution and say add reference

    Point to the Elmah.dll that you have downloaded from google code and it as it as a reference in your project.

    Next in your web.config add the following changes. -

    1. Adding Elmah Configuration Section
    1   <configSections> 
    2     <sectionGroup name="elmah"> 
    3       <section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah"/> 
    4       <section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler, Elmah"/> 
    5       <section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler, Elmah"/> 
    6     </sectionGroup> 
    7  
    8   </configSections>  

        2. Add Elmah Connection String

    1 <connectionStrings> 
    2     <add name="ElmahConnectionString" connectionString="Data Source=SUBBARAO-PC\SQLEXPRESS;Initial Catalog=ElmahDatabase;Persist Security Info=True;User ID=sa;Password=sql" providerName="System.Data.SqlClient"/> 
    3   </connectionStrings> 

       3. Add Elmah Section to your Web.config

    1 <elmah> 
    2     <errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="ElmahConnectionString"/> 
    3     <!-- Don't log 404 --> 
    4     <errorFilter> 
    5       <test> 
    6         <equal binding="HttpStatusCode" value="404" valueType="Int32"/> 
    7       </test> 
    8     </errorFilter> 
    9   </elmah> 

       4.  Add Custom Error Page ( Please note that this step is optional) you may redirect the client to a generic error page or let the Yellow Screen of Death be shown. If you choose to include a generic error page, include the following lines in the web.config

    1 <customErrors mode="On" defaultRedirect="~/Error.aspx"/> 

       5. Add HttpHandlers and HttpModules that Elmah needs. -

    1 <httpHandlers> 
    2       <add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah"/> 
    3     </httpHandlers> 
    4     <httpModules> 
    5       <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/> 
    6     </httpModules> 

     That is all the configuration we need to do to get Elmah up.

    As for an example that accompanies Elmah I wrote the sample that can be downloaded. This is what I wrote to simulate Elmah.

    I added a Button Click method which throws a NotImplemented Exception . When the website is redirected to a generice Error page (Error.aspx in this case). It can tell the client whatever error message we want to convey them.

    Then hit www.yourwebsite.com/elmah.axd to view a error log which would look similar to this

     

    The view details of Elmah would show you exactly the Yellow Screen of Death that your client sees.

    Everything above should get you up and running for using Elmah.

    Phil Haack has an excellent article to secure Elmah here . Scott Hanselman has an article to show you how to use Elmah with ASP.NET MVC here.

    Hope this article helps .

    You can download all the Code for this article here

     

    The Script that is need to be run against a SQL Database could be found here

    Cheers,

    Venkata

    Go comment!
  • Calling a Parent Javascript Method from a Child Page

    by Venkata Koppaka | Nov 28, 2009

    If we want to call a javascript method on parent page from a child page, we could use something like this-

    <a onclick=’javascript:parent.ParentJavaScriptMethod()’ >Click To Do Some Parent Specific Action </a>

    parent. and follow it up by any method name that you wish to use in parent page.

    Hope this helps

    Cheers!!!


    Go comment!
  • I am windows 7 PC

    by Venkata Koppaka | Nov 15, 2009

    I have been an early adopter of Microsoft's newest operating system Windows 7. I have used this operating system from its beta stages to RC and finally last week I have my Windows 7 Home Premium on my laptop.

     I love Windows 7 for many reasons - its faster , its more reliable and till date I haven't seen BSOD. :) . My friends say that I am blind follower of whatever Microsoft releases but I say in this tech world if some one has its say its gotta be Microsoft.

    On the other hand Dell is giving me a hard time with drivers , I contacted their support and guess what I have to pay for even driver support for Windows 7 as I didn't buy the Windows 7 from Dell, too bad.

    Anyways I am happy with my new Windows 7 and I am running Visual Studio 2010 Beta 2 and .NET Framework 4.

    Cheers

    Venkata

    Go comment!
  • My move to bluegenegeek.com

    by Venkata Koppaka | Nov 01, 2009

    This is my new home in the internet world. Previously I used to blog a bit to keep track of software problems that I have solved on My Blog.

    I have been making a cautious effort to blog more and found my limited capabilities with blogspot are also keeping me away from blogging.

    From today, I am very much committed to blog frequently on various interests here onBluegenegeek.com.

    I would blog mainly on ASP.NET , ASP.NET MVC , SQL Server, SSIS, WPF , WCF. and other technologies that I work in my day to day work. Apart from these I have decided to blog my personal interests, goals, everything that makes me who I am here, too.

     I have decided to use Sitefinity for a number of reasons. I tried WordPress but my passing towards ASP.NET said i should not be blogging on a PHP, MySQL environment. Then I tried Subtext, which I found very powerful but I thought I need more than just a blog. So I decided to move to Sitefinity, and the folks offer the community edition license for free. :)

    So here I am in the internet world with my own space.

    To know more about me please head to About Me.

     Cheers

    Venkata

    Go comment!