Posted by ken zheng on June 30, 2009
The code below is to use the global navigation bar and Inherit site master page from parent of this site
projectDetailWeb.Navigation.UseShared = true;
//set masterpage to Inherit site master page from parent of this site
projectDetailWeb.MasterUrl = projectDetailWeb.ParentWeb.MasterUrl;
projectDetailWeb.AllProperties["__InheritsMasterUrl"] = "True";
projectDetailWeb.CustomMasterUrl = projectDetailWeb.ParentWeb.CustomMasterUrl;
projectDetailWeb.AllProperties["__InheritsCustomMasterUrl"] = "True";
projectDetailWeb.AlternateCssUrl = projectDetailWeb.ParentWeb.AlternateCssUrl;
projectDetailWeb.AllProperties["__InheritsAlternateCssUrl"] = "True";
projectDetailWeb.Update();
Posted in Sharepoint | Tagged: Sharepoint, Site Master Page | 1 Comment »
Posted by ken zheng on June 21, 2009
I started to play with the SL3 with wcf, but keep getting the error when using default clientconfig file
Could not find default endpoint element that references contract ‘ProjectName.ServiceReference1.IService1′ in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.
If you look at the config file you’ll see contract=”ServiceReference1.IService1″. This needs to be a fully qualified namespace, and should be changed to contract=”ProjectName.ServiceReference1.IService1″ (or whatever namespace is specified in your Reference.cs file)
Posted in Silverlight | Tagged: Silverlight | Leave a Comment »
Posted by ken zheng on June 16, 2009
There are a few option to make it happen, I followed David’s step to modify the master page of the site:
or you can modify every page.
Posted in Sharepoint | Tagged: Sharepoint Navigation | Leave a Comment »
Posted by ken zheng on June 16, 2009
Sometime the list web part doesn’t show the change view dropdown list, I found this soltuion by just removing the web part and re-add it from the closed web part in Advanced Web Part gallery and options. It works.
See the blog for more details
Posted in Sharepoint | Tagged: Sharepoint | Leave a Comment »
Posted by ken zheng on June 11, 2009
We managed to circumvent the problem with this instrucions:
1.Click Start, click Run, type regedit, and then click OK.
2.Locate and then click the following registry subkey:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control
3.In the right pane, locate the ServicesPipeTimeout entry.
Note If the ServicesPipeTimeout entry does not exist, you must create it. To do this, follow these steps:
a.On the Edit menu, point to New, and then click DWORD Value.
b.Type ServicesPipeTimeout, and then press ENTER.
4.Right-click ServicesPipeTimeout, and then click Modify.
5.Click Decimal, type 60000, and then click OK.
This value represents the time in milliseconds before a service times out.
6.Restart the computer.
Posted in Handy Tips, SQL | Tagged: SQL Report Service | 2 Comments »
Posted by ken zheng on June 3, 2009
It happens to me a few times, I can’t set my desktop image. What you need to do is go to your registry. HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System, delete Wallpaper key and now you can set the background image
Posted in Handy Tips | Leave a Comment »
Posted by ken zheng on June 3, 2009
Posted in SQL | Tagged: Insert Script, SQL | Leave a Comment »
Posted by ken zheng on June 2, 2009
. I’ve used the method for this previously in the solution,BreakRoleInheritance(false), so that no inherited roles are copied, but then this was done on a POST request and now it should do almost the same during a GET request, that is when the user navigates to the page.
All this is done under elevated privileges and looks something like this
SPSecurity.RunWithElevatedPrivileges(delegate() {
using (SPSite site = new SPSite(url)) {
using (SPWeb web = site.OpenWeb(url.Replace(site.Url, string.Empty))) {
web.AllowUnsafeUpdates = true;
Guid guid = web.Lists.Add(name, string.Empty, SPListTemplateType.DocumentLibrary);
SPList list = web.Lists[guid];
...
list.BreakRoleInheritance(false);
...
list.Update();
}
}
});
This gives me the following error when running during a GET request.
“Updates are currently disallowed on GET requests. To allow updates on a GET, set the ‘AllowUnsafeUpdates’ property on SPWeb.”
If I rewrite the code and change the BreakRoleInheritance(false) to BreakRoleInheritance(true) and set the AllowUnsafeUpdates to true once again it works fine and I have to manually get rid of all the roles.
Why is it so?
If you step through the code in the working sample you will see that after the BreakRoleInheritance(true) line the AllowUnsafeUpdates property of the SPWeb object has changed to false. The AllowUnsafeUpdates property will reset to false whenever any ISecurable object changes their role definitions, and in the BreakRoleInheritance method you have a call to an internal function that invalidates the SPWeb object which resets the AllowUnsafeUpdate property.
The exception is then thrown after breaking the role inheritance and when the method tries to remove the roles from the list. I initially thought that it was the other way around and therefore was a bit confused.
So the correct way is this:
SPSecurity.RunWithElevatedPrivileges(delegate() {
using (SPSite site = new SPSite(url)) {
using (SPWeb web = site.OpenWeb(url.Replace(site.Url, string.Empty))) {
web.AllowUnsafeUpdates = true;
Guid guid = web.Lists.Add(name, string.Empty, SPListTemplateType.DocumentLibrary);
SPList list = web.Lists[guid];
...
docLib.BreakRoleInheritance(true); //Exception throw here when the parameters is "false"
web.AllowUnsafeUpdates = true;
SPRoleAssignmentCollection roleAssigns = docLib.RoleAssignments;
for (int i = roleAssigns.Count-1; i >= 0; i--)
{
roleAssigns.Remove(i);
}
list.Update();
}
}
}};
Reference:
http://www.wictorwilen.se/Post/BreakRoleInheritance-and-AllowUnsafeUpdates.aspx
http://www.delphi-ts.com/blogs/lozzi/2008/10/31/TheSecurityValidationForThisPageIsInvalid.aspx
Posted in Sharepoint, VS2008 | Tagged: BreakRoleInheritance, SharePoint Security | Leave a Comment »
Posted by ken zheng on June 2, 2009
One day, when my VPC was closed unexpected, the IIS can’t restart and throw error:
The Windows Process Activation Service encountered an error trying to read configuration data from file ‘\\?\C:\Windows\system32\inetsrv\config\applicationHost.config’, line number ‘0′. The error message is: ‘Configuration file is not well-formed XML’
Luckily IIS makes a backup each time you make a change. All those versions are stored in the folder C:\inetpub\history\. All you have to do is to copy a former applicationHost.config file into the C:\Windows\System32\inetsrv\config\ working directory.
Posted in Handy Tips, Sharepoint | Tagged: applicationHost.config, IIS 7 | 3 Comments »
Posted by ken zheng on June 1, 2009
We have 2 web front end server for Sharepoint, but one of them is 32-bit and not upgraded which caused some timer job failed. To check the Immediate Alerts I followed this blog:
a. Open the command prompt and go to the 12\Bin folder. Run this command and see whether alerts are enabled for the web application.
Stsadm.exe-o getproperty -url http://problemsite -pn alerts-enabled
The expected output is . If you don’t get this, run the following command to change the value.
stsadm.exe -o setproperty -pn alerts-enabled -pv “true” -url http://problemsite
If the property is Yes and still the alerts are not sent, toggle the property from Yes to NO
and then from No to Yes. This may delete all the existing alerts and warn the customer
about this.
b. Check the property job-immediate-alerts schedule through command prompt. Run this command from the 12\bin folder. If we have issues with Scheduled alerts like daily or weekly, then check the property job-daily-alerts and job-weekly-alerts.
stsadm.exe -o getproperty -url http://ProblemSite -pn job-immediate-alerts
The expected output is
. If you don’t get this, run the following command to change the value.
stsadm.exe -o setproperty -pn job-immediate-alerts -pv “every 5 minutes
between 0 and 59″ -url http://ProblemSite
c. Confirm the above step through the UI. Central adminàOperationsàTimer Job Definitions and ensure that a job named Immediate Alerts is present for the web application.
I run the above commands which display all right. So I turned off the 32-bit server for one night. And on the next morning, all the Immediate Alerts back tot he 64 bit server works fine.
Posted in Sharepoint | Leave a Comment »