General Bloging

Development and Stuff

About the author

Author Name is someone.
E-mail me Send mail

Recent comments

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2010

SharePoint 2007 Show Error Messages for Debugging

Debugging SharePoint errors is  a pain.  You normally get the the  "An unexpected error has occurred" error message is shown.

Sometime there is nothing in the event log or trace log.

To enable detailed error messages in the browser do the following in web.config 

<SafeMode MaxControls="200" CallStack="false"… />  change to  <SafeMode MaxControls="200" CallStack="true" … />

The customError setting must be changed to "Off":     <customErrors mode="Off"/>

After these changes, the "An unexpected error has occurred" should no longer be shown and you should a standard ASP.NET error page.

Currently rated 5.0 by 2 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by gurney on Tuesday, March 18, 2008 8:58 AM
Permalink | Comments (1) | Post RSSRSS comment feed

Changing list ID for a customised page

Once you have customised a page in Sharepoint designer using data views the list id etc are embeded into the page.

If you the export and import the site, all id become invalid, the code below is how to restamp the customised page with the new Id. 

try

{

//using (SPSite site = new SPSite(SPContext.Current.Site.ID))

using (SPSite site = new SPSite(SiteURL))

{

using (SPWeb Web = site.OpenWeb(WebURL))

{

//This bit of code restamps all the list guid that SPD

//put into the page source for our customised project home page.

//When the site is exported and re-imported all lists get new ID hence the page is

//broken this fixes it for the new site.

byte [] bfile = Web.Files["default.aspx"].OpenBinary();

System.Text.Encoding enc = System.Text.Encoding.ASCII;

string myString = enc.GetString(bfile);

//re-stamp the guids from the default projector site with the new ones that

//have been created in this site.

SPList list = Web.Lists["List Name"];

myString = myString.Replace("69D01208-49F1-43BC-ABF9-550A75BD1A54", list.ID.ToString());

bfile = enc.GetBytes(myString.Replace("???",""));

Web.Files["default.aspx"].SaveBinary(bfile);Web.Files[

"default.aspx"].Update();

 

}

catch (Exception ex)

{

Console.WriteLine("Exception " + ex.ToString());

}

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by gurney on Monday, March 10, 2008 8:10 PM
Permalink | Comments (1) | Post RSSRSS comment feed