Imagine your web application is having some issues and you have configured the application to show custom error messages instead of real exceptions. So one way of knowing what’s happening is, to change the web.config to throw real exceptions instead of custom error messages. And I am sure, your site viewers definitely not going to like it. So is there any other way, that we can use to see what has happened apart from using some logging? There is.
IntelliTrace can be quite useful in such cases and in this post let’s see how we can use IntelliTrace to collect information of an ASP.NET application running on IIS. So without much information let’s dive in to see this in action.
I have created a MVC application and I am having that application running on my local IIS. Currently it is working perfectly well. I can login and navigate around.
![image image](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgk3Fru-7_FoeZ2H8OxMrBMPjgXK4bWsMU08vPSz5X3rsVNvM4PNRW45aB2oAX6dEvJQroy7Hxz1oLJXJNB-6j7dIcr4YKkId0WwY0Qi-Tolt7ze_aG0QqJGYPuiWhA7xXEufmn76yPWPk/?imgmax=800) |
ASP.NET Application Running on IIS |
Now to introduce a bug, I am going to change one of the columns which is related to login functionality. So in the applications’ database, I am going to change the column “UserName” to “User_Name” in the AspNetUsers table.
![SNAGHTML5f0e696 SNAGHTML5f0e696](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOfYPKPQf3O29Kl-FtGN8erbCZRgvlAzD_A4Ak2oAUC5GPxLkfUhT1d2hu6GILopTTPwLlUSed0tklZ4d7VqKpg3QygB_ZmD2aVVzXjGO5t08TVo_IlFisBzPZle7FcazzkxwGwJeTZb8/?imgmax=800) |
Changing Table Columns to Produce a Bug |
Now I am trying to login to the site back.
![image image](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzKoOAadrZgLhj6MzxqzqgK9QuMifPA0iTsQORus1ck_FtQfMxdgo3TbrM2N-FEb20G3i2Q4UjDXGq4LshOnJjaFfZEtcwi7DwiKvUkZzv0UiWHTLUgkGZsNY7s915H6X87IiJ4DTMjZ8/?imgmax=800) |
Error |
As expected, I am getting an error. The error message is not so informative and If I don’t know a column in the database is changed, I definitely am in trouble, figuring what went wrong here. Now let’s see how I can use IntelliTrace to find out what has happened.
First you need to download and extract IntelliTrace Collector which you can download from
here. This exe is being updated every 3 months by Microsoft and it is recommended to use the latest every time. I am creating a folder named “ITraceCollector” in my C: drive and I am placing the downloaded executable there. Next what I need to do is run the executable.
![image image](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHH0xFSunxMYTZOujo6HUxNjrfleXcUbvg__sJ17tSLODAxVWeDHzJ_-vkhvY5ym_54Gdund96aSC7K10W44K-5o1lGQM3raHrgXJONyh3fkWOfKCczawREJ7Hbu_fUdrlYPCY0M8Sc7Y/?imgmax=800) |
IntelliTraceCollector |
You need to agree on the license terms and conditions and browse for an folder to extract the content (here, after the extraction the only file I will be getting is IntelliTraceCollection.cab file). Here I am giving my extraction destination as,
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\IntelliTrace\12.0.0
One thing to note is, if you have Visual Studio installed, based on your version of Visual Studio you can find the already extracted content in above mentioned folder (if you are using Visual Studio 2012, the path would be “C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\IntelliTrace\11.0.0”). When the Visual Studio is installing, it will place a IntelliTraceCollection.cab file there, but it is not the latest. So again the recommendation is to use the latest. Since I don’t want the latest IntelliTraceCollection.cab to be in a separate folder, I am just giving the original path as my extraction path.
Once the extraction is done, copy and paste the new IntelliTraceCollection.cab file to “ITraceCollector” folder which I have created before. Next I need to open up the command prompt as Administrator and run the following command to extract the content of IntelliTraceCollection.cab file.
![image image](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuBTeL-chr0MXebEP2VsvuHMxzjQDOdWvfZ-TALHXn3tGESGKsHxVQPJIN34_ZpUKkxGjoJdSLOVFpPBPyfrz3QPhIHDl6cyCK7rxxOsnotV1dot-zL1nzEznjDAXT3qvCvnRUtdLMeW0/?imgmax=800) |
Expand IntelliTraceCollection.cab File |
cd C:\ITraceCollector
expand IntelliTraceCollection.cab F:* c:\ITraceCollector
Above what I have done is, I am changing the current directory to “c:\ITraceCollector” and I am issuing a expand command. First parameter (IntelliTraceCollection.cab) is the cab file to be expanded, second parameter (F:*) specifies all files in the cab file should be expanded. Third and the final parameter (c:\ITraceCollector) is the destination.
Once the command got completed, I can see a whole bunch of folders and files created in “C:\ITraceCollector” folder. The next thing I am interested is the default collection plan for ASP.NET applications which can be found in the “c:\ITraceCollector” folder. I need to create full collection plan and I am going modify the existing default collection plan and save as a new plan. For that download and install the “
IntelliTrace Collection Plan Configurator v1” from
here. Once installed, open up the “
IntelliTrace Collection Plan Configurator v1”.
Go to File –> Open.
![image image](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0aO7q8xmhw_Li0C3y0OVmg-RGSAM0bVSwi9VUbjvFYE0hlXoviPVyzIiNe01scOOVBo2hBRV58NPe1cLkluB4kb5qw8LvuG7FgvkqTmlYmTtTnWE1i2rGq2NcH5gT0sUq6yno5_E_fqY/?imgmax=800) |
IntelliTrace Collection Plan Configurator |
Select the “collection_plan.ASP.NET.default.xml”
![image image](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_2gg_7qyOiDxAy73SkJt4wnGeou-KnRdk3Ud9YALHsStxGH7ImFJXZBJRxi0nMVaMg36TvpkWU8sqozmlRC9L_o7Cvn3E3nGLke3gEu-7DHP7NDkE_M7oyqwGt-CL3s0uxEpTS699c_o/?imgmax=800) |
Opening Default ASP.NET Collection Plan |
Once the selected collection plan is opened, go to “IntelliTrace Events” tab and select all. This will cause the collection process we are planning to run to collect all the information of all the IntelliTrace events.
![image image](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgG038M3oALfT0Q0kEXgoreMmnov8fcqgjM_4wF2j9vkaX6aScNKDt-tb6Tb2TO12rxKxiWwc_qElqmhnN3JKrx6K9sHx3_qfoxm5gHw2Pcn4t3SIZnzfbraZq85ReXfR_ZPpPOrr1s3zk/?imgmax=800) |
Selecting All IntelliTrace Events |
Once that is done, let’s go ahead with saving the file and I am giving a new name as “collection_plan_full.xml”.
![image image](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLR-lE0bQ8ZVCgUn-ObhnAvLv8Keys4m_SYuB0bR2dalClus7Kio-hCpjcP3Wc01aNJ3UwmC_Jf-jnScZNJqaqU5oevYv4h5V1658VyLmW0jDyLjamEBKw9U_zal3KMLudwjKUqriyDSI/?imgmax=800) |
collection_plan_full.xml |
Now the next thing be done is initiate the IntelliTrace collection process. For that let’s open up the PowerShell as Administrator.
First I am importing the PowerShell module for IntelliTrace. You can find it “C:\ITraceCollector” folder.
![image image](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQjXTOpCz9aJSxEw52LuEFKkVrYcq-FpykvUznrhNrTvXxDGIMh00VFL0h3XtLOizzYrdDbbfVrv42_7vcWv3-ltaNF8FVw_voyDzVJs778DXGjgUu3rFCOA99QXKkwm_MRcIBWFE8Om0/?imgmax=800) |
Importing IntelliTrace Module |
Import-Module c:\ITraceCollector\Microsoft.VisualStudio.IntelliTrace.PowerShell.dll
Now let’s check what are the available IntelliTrace commands by running Get-Help command.
![image image](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhfCHzT7Eu8lC0PRfHNgX_d-rFj2XtM70T3TnBczFbtBvG8ILa7YC9H24vxmaByw_aCUmMB_3FIhEW5FAtdqwdZd7ilAz3tdfMERtsEeFlkUpvvTqfYXGjmH1toArGj-JBc8foXzeWIYYQ/?imgmax=800) |
Get IntelliTrace Help |
There I have a command named “
Start-IntelliTraceCollection”. I am issuing that command.
![image image](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEher-q0N2X0Ks8mE8IoakrO9LMjzlSl5oVIdi9yoUK_FuD2STAVgmXLX0APjT2ljdeuvIOgyaAyPVOqd7-3ASz6I9De3pr9mt1OhJQKNQNQU9hASYPjd2D6Z6acNB4v_hfgZb28BA6zOKk/?imgmax=800) |
Starting IntelliTrace Collection |
It is asking for name of Application Pool. I am getting the Application Pool by going to IIS, right clicking on my application and Manage Application –> Advanced Settings.
![image image](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDcu0qI5b3gXFZR_oPspwdVdtLIno6MJKNgp2gOPXb12foc0BydEVziTJhR7ba36gFp1P19r_KOUY7uDBFgezF8hUkq0bHjJiSWXu-8RX9AkDy2uIL9cFArydxP3qvVr0DXoHEwXGX8hM/?imgmax=800) |
Application Properties |
![image image](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNvek5b_MHP5NqVD4lmvonObx2SeKaoNomk_vDqjvecCS-7O8zVfdqhmQV2dEHj-wthFpG2OODGjfbhBYxJ01tSYA1jNys4aUIQsYyXB9iFrWB6dK2B5OCp8Dyvr8Zh-Nj2sBqlXH6ALg/?imgmax=800) |
Getting Application Pool Name |
I am copying the Application Pool name which is “DefaultAppPool” and pasting it in the PowerShell.
![image image](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhr0QlbZ-rcURUA1HXWidpwD1Is3BExOMlInfX8ez7E6D3a0y0Da_zk9nabGOFwP-pzlWEXQ5yzOsD68whnQFBhD4xCasXZ3fnQ-kBHJ3u3io8eucohOvVPqwF-P5p-0V_Xy7QtQrZoFk0/?imgmax=800) |
Application PoolName |
Then it is asking me for the collection plan. I have created a full collection plan before and I am giving the path of that particular xml file which is “C:\ITraceCollector\collection_plan_full.xml”.
![image image](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4-Zm8_DXFPS-gJsiWNKcutFk40q-WWisms6Fd0z41ymUNqVibEZWsqAeAqgtbWHwg5LJ_y37nzVmd98-BQO7DbOwoIVr0ilmomPnPKtsKGUh9EgkpH2K269mY2S0isqOfcZXvWPMzEkQ/?imgmax=800) |
Collection Plan Name |
Now it’s asking for the Output path where trace files should be created. For that I am creating a folder named “ITraceLogFiles” in my C: drive and I am giving that path and hitting on enter.
![image image](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgNfRN84yz5TI-OAzqv1EU8dczIABmCZcfTgkDavZYQIfl1HPoEq6F2kZUw58rHt6afOcMabcpfv8stvptxBEZN6m2HICCn6jypQaBn_ldru3M99W13NjVwwY6C83maYKKJmGp1G27znE/?imgmax=800) |
Output Path |
I am thrown with an error “The following application pool requires write permissions to the output directory: "NTAUTHORITY\NETWORK SERVICE", "C:\ITraceLogFiles".”. Now let’s give full control to the folder “C:\ITraceLogFiles” for the user “NTAUTHORITY\NETWORK SERVICE”.
![image image](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1q5hbQkQtgTbpixTiyBUnxewOAaNOXGpITi0Q1r1KvEU7ZtM9UAq43hirn3cMC3-gaYet52EB5X5Sc0ZnAAsCk6ou1xXV8flsIK176G3RDDzaRlZO2BnhHtdn6LjO5RBN0L_-KJFl8c8/?imgmax=800) |
Setting Permission to ITraceLogFiles Folder |
After doing that, let’s run Start-IntelliTraceCollection command back again and it’s time let’s make it short by issuing the command from one line.
Start-IntelliTraceCollection "DefaultAppPool" c:\ITraceCollector\collection_plan_full.xml c:\IntelliTraceLogFiles
![image image](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEje06-M82QKprJJ8sNZOtEo3_3eVG2Mn73Ap8QIAgkfYh7cdfqPXCcNVqHdoiVi2z6NU9BQCoHZXN_MELqwYLIolZ-LkqraiUmDa3d1LpkoQPYXNAilWncIvqckjn0JUBcI_IC3-unFhUg/?imgmax=800) |
Start-IntelliTraceCollection |
No errors this time and it’s asking me to confirm the action. I am entering “Y”.
Now, IntelliTrace collection process has been started. Now let’s try to log in to my web application back again so those events will be collected by IntelliTrace.
![image image](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0oFSGb1n02NTvM3vfScEUBjIJZH6PDL6zSNnIQgR9KEJRSNaJtJjTZQFJx2Gs-2aY0lgSBgGTl5LPUbsbNqq_e3Z-ZLB3lZH4T9wBtYBIVXCGpvdaXt3TshZMPDBmdZkFUxWPPKiYo8Q/?imgmax=800) |
Error |
Again, I am getting the error. That’s fine and let’s examine the “C:\ITraceLogFiles”.
![image image](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0nzXfes8pUDyGUa20_SqXc-sy5Jb01aQ8Y_PpVdxF1a8LO6b5sQH_1OtKIsVR_S6vz4dn93wBRuXk-4o0-YIwy5Z1BVzRsB0FONIvtEpa5WjRo-CY8y-IC4JIvUYoSyVNHdzfg_lAsBg/?imgmax=800) |
Created iTrace Files |
I can see a iTrace file created there. Since now I know my actions on the web application has been traced by IntelliTrace, let’s stop the IntelliTrace collection by issuing Stop-IntelliTraceCollection command. Now it is asking for the Application pool and I am giving it as “DefaultAppPool” and like previous, I am confirming the action.
![image image](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgvMm10dDYBe2v163oGkY_0TQRXainMqksBzRolD2CW9gPCVOmL38jFyyIaW8Pg6txN_d2hbDGFdVUACCpzVBZzoS-rbFa08qyfQBK2ITv4WMjmvkwR9Hrxbe5A7v1m36cQUZwYqwnIrzQ/?imgmax=800) |
Stop-IntelliTraceCollection |
Again you can do this by issuing following command in one line.
Stop-IntelliTraceCollection DefaultAppPool
Since IntelliTrace collection is now stopped, let’s open the iTrace file using Visual Studio. You just have to double click on that file, it will be opened using Visual Studio.
![image image](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5Bu7TNEaHYSQ6Zl2S1dNfJR90VuPSa7XzW9JT1SJ79sVaa973xojevDN7RTyFTBjNxzodkPi2ltngbm5OdzZ689_QdBDVr82bRV-aLtSEpVPxRKiWOQimbXV6Nrn8wkZ1KQ4Fj9eHLYc/?imgmax=800) |
IntelliTrace Events |
After scrolling a bit I can see several events logged saying “Invalid column name ‘UserName’”. And when I double clicked on an event, it starts to debug with the IntelliTrace window.
![image image](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiH8-meee6GtHkVo4znfPI4s55yh7Cuya5VJahHENxCioaz91K-caKMRcZGLHSbEUHVqV-ZUou9hJcsJV3d8SrdXeqp9OBTzCFRkwhO-urIO_uIAbxjQe4_41tcUZUDdA5BqcjuGCnKUlc/?imgmax=800) |
Debug Mode |
Since the error is thrown from ASP.NET Identity, I cannot debug the code here. If an error is thrown in code written by me, I should be able to directly navigate to the code.
So that’s all and hope you would found this interesting.
Happy Coding.
Regards,
Jaliya