Scott Cate Weblog 

scott.cate@myKB.com
http://scottcate.myKB.com



Scott Cate KB > ASP.NET Code Samples - Findings > Tracing & Debugging Start Over
Search the Knowledge Base
 
Start Search in the Following Category
Date Modified
Tuesday, March 01, 2005
Securing Trace.axd - Remote & Local

In the Arizona .NET User Group (http://www.AZDNUG.com) that I run we were talking about tracing and all the awesome features and abilities it has and we ran into a problem.

You may know that if tracing is enabled and is not specifically flagged as LocalOnly="True" then you can access Trace.axd from anywhere. This can be very dangerous if your are Trace.Write(ing) things like

  • Configuration/Connection Strings (which is a terrible idea)
  • SQL Strings
  • Variable Name/Value Pairs
  • Whatever

So we figured out a way to secure the Trace.axd file. It's pretty simple actually. The ASP.NET Worker Process is in charge of rendering the Trace.axd file so that means we can secure the file through the web.config file.

Add the following additions and/or modifications to your web.config file.

1:     <location path="trace.axd">

2: <system.web>
3: <authorization>
4: <allow users="ScottCate" />
5: <deny users="*" />
6: </authorization>
7: </system.web>
8: </location>

and then modify your Trace Statement

1:     <trace enabled="True" requestLimit="10" pageOutput="False"

2: traceMode="SortByTime" localOnly="False" />

Because your web.config turns on the tracing, the Trace.axd file is activated and then because your location security only allow certain users, you've now secured your trace.axd file

Happy Coding.
scottc@myKBPro.com

Article References
Application-level Trace Logging - ASP.NET QuickStarts Tutorial
ASP.NET Trace Functionality
Displaying Trace Messages on the Page


All rights reserved. All details are the personal opinion of Scott Cate.
All trademarks referenced are the property of their respective owners.
Scott Cate is a lead programmer for www.myKB.com and
owner of The Arizona .NET User Group and an all around nice guy ;)


Knowledge Base Software - myKB.com

 

Cameron Cate Pictures
Cameron Cate Pix

Site Navigation

Home
Knowledge Base
Wiki Discussions
Photo Album

Sites I Own & Run


Easy Search ASP.NET
mykb.com knowledge base software logo
myKB.com
Knowledgebase Software

KBAlertz.com
Arizona .NET user Group
Group Leader

Affiliations


ASP.NET MVP
2004
2005
2006
2007
2008
2009


Blog Sites I Read

Brady Gaster
Rob Howard
G. Andrew  Duthie
Robert McLaws
Alex Lowe

World of Scott.Net

Scott Guthrie
  -  Father of ASP.NET

Scott Watermasyk
  - .Text (Weblog)

Scott Sargent
Scott Mitchell
ScottG.net
Scott Bellware
Scott Forsyth
Scott Hanselman
Scott Cate

Favorite Books


ASP.NET Cookbook


First Looks @ ASP.NET 2.0