Web.config Custom Errors Message

September 1st, 2011 No comments

This is a little page I like to call the yellow page of death.

Custom Errors Screenshot

If you’ve done much ASP.Net development at all I’m sure you’ve run into this error, and probably had the experience of trying to set <customErrors mode=”Off” /> but yet this error still displays. I figured I would post a nice little algorithm I use whenever I get this error message and setting the Mode to Off doesn’t work:

  1. Verify the folder is an application in IIS
  2. Verify the application is set to the proper version of .Net and in the correct application pool for that version
  3. Make sure the web.config is proper XML
    • This can be done by renaming web.config to web.xml and loading it in IE
  4. Set the web.config in the parent folder to <customErrors mode=”Off” />

I’ve found that by running through all these I have always been able to fix this error message so that I can get a much less general message about what is actually going on.

    Export Access Data to Excel

    July 31st, 2011 No comments

    Recently I had to export the data for an Access database into excel spreadsheets. This should have been pretty easy because they’re both Microsoft products and Microsoft likes to tout the interoperability of its products. At first glance it looked really easy, just right click on the table you want to export and go to export to Excel. The problem was this isn’t just some access database, it’s the mother of all access databases.

    There are about 4 million records in the table (I was suprised access could handle that many records) and the latest version of Excel only supports about 1 million rows so I was going to have to generate about 4 excel spreadsheets. This seems like an easy SQL 101 problem, create 4 queries, one that selects records 1-1,000,000, then 1,000,001 to 2,000,000, and so on but to my surprise that was basically impossible because there was no auto number field on the table. Well I thought this shouldn’t be hard I’ll just add an autonumber column then write my queries but the problem with that was whenever I tried to add the field it would increase the access database size above the maximum size of 2GB.

    Next I thought well I’ll just select top 1,000,000, generate the excel spreadsheet, then delete the records I selected and repeat. This idea however wasn’t possible because the table didn’t contain any primary key fields so I didn’t really have an easy way to delete the records I had already exported. Also access doesn’t have any type of row_number method (like Sql Server) so I couldn’t generate a pseudo primary key on the fly.

    Finally I just gave in and installed Sql Server on my computer and imported all the data into it. Once the data was imported Sql Server had no problem letting me add an identity field to the table (although it did take about 5 minutes for the script to complete). Once that was done I just had to write my select statements when using the export wizard in Sql Server.

    In closing I think I’ve found a nice example of something I already knew… friends don’t let friends use Access databases for large datasets.

     

    Categories: Uncategorized Tags: , ,

    jQueryUI Tabs – Get Selected Tab Element

    February 21st, 2011 No comments

    So I spent the last hour or so trying to find out how to get a reference to (or the ID of) the selected tab element (or panel) from jQueryUI. All the searching I did kept coming back with how to get the selected index but that didn’t do much good because I needed to do a .find on all elements inside the selected tab so I had to have a reference to it.

    Finally after getting nothing but a few hints I opened up firebug (best addon ever) and just did:


    $("#MyTabs").data()

    And dug through the output with firebug. I saw that there was a tabs element inside that contained a panels array so I found what I was looking for. I’m pretty sure this isn’t a documented way to get what I was looking for but I couldn’t find any other way so use at your own risk.


    var Tabs = $("#MyTabs");

    Tabs.data("tabs").panels[Tabs.tabs("option", "selected")]); //gives you the html element that is being displayed for the selected tab

    Keep in mind this returns a reference to the html element that is displayed when the current tab is selected. If you want it to be a jQuery object just surrond the second statement with $().

    Code Coverage During User Test

    February 14th, 2011 No comments

    I had to make some pretty major changes to a high profile website at UC. Developing these changes required a different approach than I’m used to, normally I’ll make one or two changes, test to make sure those work, and then make a few more changes. In this case I had to basically rewrite a class that was already in use to be more generic and I wouldn’t really be able to test anything until it was completely done. I knew that testing time would be a little difficult because everything would need to be fully tested together. I thought that it sure would be nice if while testing I could see the code coverage results so I could make sure I didn’t miss anything. After a little searching without any results I asked this question. The first post pointed me to this blog post, which was helpful but it seemed like that would only be useful if you were using a Web Application that would build into one dll. What I was developing was a Web Site that dynamically compiles the cs files on the fly so there was no way to do the code coverage instrumentation (that I could find at least). I did a little searching to see if there was any way to do that in the web.config and all the results I found seemed to be for profiling an application not code coverage. Finally I found a page that was talking about creating manual tests and I got the idea that maybe if I set up a manual test and just left it running while testing I would then be able to see all the code coverage after everything was tested.

    Here’s the steps you need to take in order to be able to see the code coverage while a user is testing a website

    1. Add a test project to your solution that contains the website you want to test.
    2. In your solution explorer you should have a new folder called Solution Items and there should be a .testrunconfig file open that file
    3. Click on Code Coverage and make sure to check the box on your website (and any other dlls you want to see code coverage for)

      test run config example

    4. In your test project make sure you have you have a manual test in it, if you don’t add one (you don’t need to configure it in any way)
    5. Add a WebTest to your test project, when it pops up with the test recorder just browse to the default page of your website and stop recording

    Now all you need to do is run all tests and when you get to the stage of the manual test you can do all the user testing and once that’s done accept the test and see how much of the code was hit.