Navigation Bar

Sunday, 1 July 2012

Debugging SharePoint code in Production


Recently I was asked to troubleshoot production code. Unfortunately we did not have pre-prod or staging environment.

In production, you have to be very careful. You can’t deploy anything without going through some checks (or build pipeline).
Then what I did was very simple thing. Imagine what would have I done!!!
I chose a SharePoint layout page that only displays links. Guess which page it was? Yes it was _layouts\settings.aspx page.
I copied _\layouts\settings.aspx to _layouts\Masood\settings.aspx and modified with my debugging code.
I wrote code in scriptlet.
<%
Response.Write(“Beginning of my debugging code...”);
YourDependencyClass obj = new YourDependencyClass();
obj.SomeMethod();
%>
The other thing I did was I wrote whole classes between< % and %> and fortunately I found the issue. Following is an example

< %
public class YourDependencyClass {
   public void SomeMethod(){
          //your logic…
   }
}%>
I hope that will work for you if you need to do troubleshoot in production environment.

No comments:

Post a Comment