Monday, September 27, 2010

Configuring Location based Metadata in SharePoint 2010

Location based metadata which manages to inherit default metadata values from its immediate parent. This is a nice feature in SharePoint 2010 and its available out of the box with few configuration steps.

Configuring default metadata

1. Add the required folder structure to your document library, in this example it is

Root->Hardware->Router
Root->Software->Microsoft

2. Add the required column to the document library, in this example it is "Classification" and click on "Column default value settings"
click on the required  folder in left pane, choose the column name in the right pane. You will be seeing a popup as below
Change the radio button to "Use this value" and enter the default value in the text box. This value will be inherited in all the documents which will reside in this folder.

Provide a different value for the subfolder "Router" inside the Hardware folder.

Upload a file to Hardware folder and note the "Classification" metadata is pre-populated
Similarly if we upload a file in "Router" folder the classification will be pre-populated as we've provided earlier.

SharePoint 2010 registers a Item Added event reciever(Microsoft.Office.DocumentManagement.LocationBasedDefaultsReceiver ItemAdded) to the document library upon first access of this feature.

Refer the following MSDN articles for more info
http://msdn.microsoft.com/en-us/library/microsoft.office.documentmanagement.metadatadefaults.aspx
http://msdn.microsoft.com/en-us/library/ee557925.aspx

70-542 MOSS 2007 App Development completed

Completed 70-542 Microsoft Office SharePoint Server 2007, Application Development last week end

With SharePoint Server 2010 in the ring, it's late but good to complete the 2007 series before jumping to 2010 bandwagon

Useful links for preparation:

  1. http://paulgalvin.spaces.live.com/blog/cns!1CC1EDB3DAA9B8AA!192.entry
  2. http://thepointyheads.com/2009/10/microsoft-exam-70-542-comprehensive-list-of-training-materials-for-every-section-of-the-exam/

Wednesday, September 1, 2010

Unlocker : Error debug privileges

If the user doesn't have permission for remote debugging,Unlocker  will fail with the following error message

Error Debug privileges

Provide Debug privileges for the user in the target machine to satisfy Unlocker

Start -> Run -> "secpol.msc" then click ok
Expand "Local Policies" in left pane
click the "User Rights Assignments" folder
On the right hand screen double click "Debug Programs"
Click the "Add User or Group" button
Click the "Advanced" button
Click the "find now" button
select your "user logon name" and then click the "Ok" button



Changes will take effect after a logoff or a reboot. 

Tuesday, August 24, 2010

How to enable SharePoint to handle the forbidden files ?

We tried to store files which has the (.rules) extension in document library, once we added all these files to the document repository,we tried to download these files by clicking on it. It ended up in an error message stating.

This type of page is not served.
Description: The type of page you have requested is not served because it has been explicitly forbidden.
The extension '.rules' may be incorrect. Please review the URL below and make sure that it is spelled correctly.
Requested URL: /Financial Documents/TestRulesSet.rules
But the Send to->"Download a copy"  option works as expected. When we use this method we are asking the OOB download.aspx page to download the content for us.

 After re-collecting the basics of SPHttpHandler which handles all the SharePoint requests. This handler is forbidding this specifying file type. so the solution is to
Add a http handler before SPHttpHandler which serves this file type as expected

 Open windows explorer , navigate to the virtual directory and open web.config with your favorite text editor

 Find section and the following segment below after the remove block, so after adding the httpHandlers section will look like below

 <remove verb="GET,HEAD,POST" path="*" />
<add verb="*" path="*.rules" type="System.Web.StaticFileHandler" />
<add verb="GET,HEAD,POST" path="*" type="Microsoft.SharePoint.ApplicationRuntime.SPHttpHandler...

 Do an IISReset

Warning : Do understand the risk of exposing these forbidden files using StaticFileHandler

Following is the list of Http handlers which takes care of the frequently used ASP.NET file types
  • trace.axd - System.Web.Handlers.TraceHandler
  • aspx - System.Web.UI.PageHandlerFactory
  • ashx - System.Web.UI.SimpleHandlerFactory
  • asmx - System.Web.Services.Protocols.WebServiceHandlerFactory
  • rem - System.Runtime.Remoting.Channels.Http.HttpRemotingHandlerFactory
  • soap - System.Runtime.Remoting.Channels.Http.HttpRemotingHandlerFactory
  • asax - System.Web.HttpForbiddenHandler
  • ascx - System.Web.HttpForbiddenHandler
  • All sharepoint request - Microsoft.SharePoint.ApplicationRuntime.SPHttpHandler
  • Reserved.ReportViewerWebControl.axd -Microsoft.Reporting.WebForms.HttpHandler

Thursday, August 5, 2010

SharePoint 2010 SPSite : System.IO.FileNotFoundException

Can any one spot an error in the following snippet. Following snippet tries to open a SPSite, SPWeb and tries to open a List to get it item count. All objects exist in the server and this code was built with VS 2010 for SharePoint 2010 in x86 Debug mode.

I ended up with the following exception

System.IO.FileNotFoundException was unhandled
Message=The Web application at http://Foo could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application.
Source=Microsoft.SharePoint
StackTrace:
at Microsoft.SharePoint.SPSite..ctor(SPFarm farm, Uri requestUri, Boolean contextSite, SPUserToken userToken)
at Microsoft.SharePoint.SPSite..ctor(String requestUrl)
at ConsoleApplication1.Program.Main(String[] args) in C:\Users\Administrator\documents\visual studio 2010\Projects\ConsoleApplication1\ConsoleApplication1\Program.cs:line 17
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:


After a couple of minutes I got things straight. There was a mistake in the build, as a basic rule while developing for SharePoint 2010 all your build should be in x64 mode not in x86 mode.

Basic mistake, but it hurts and the error message is not really helping...

Tuesday, July 20, 2010

Load testing SharePoint pages using JMeter

Recently I found myself in search of an open source web load testing tool to do testing and to measure my SharePoint application's home page performance. Apache Jmeter a feature rich tool to prepare a load test which helped to arrive at the statistics.
JMeter Java desktop application which comes in an executable jar file and can be downloaded from here. Obviously you need java runtime(JRE) to start this jar file.
open the bin folder and open ApacheJMeter.jar file from windows explorer
Right click the Test Plan and add a Thread group

Provide the applicable values


Thread group configuration
  • Name - Give a name to store all settings in a jmx file.
  • Number of Threads - Number of concurrent users to hit the page
  • Ramp-Up Period - Thread acceleration period If the number of threads used is 10 and the ramp-up period is 20 seconds,it will take 20 seconds to create those 10 threads.i.e,one new thread in every two seconds, want to create all threads in a single shot, put zero in this
  • Forever - this option tells to keep sending requests to the tested application indefinitely. If disabled, JMeter will repeat the test for the number of times entered in the Loop Count box.
  • Loop Count - the number of times it has to repeat the test, it is effective only if the Forever check box is unchecked
  • Scheduler - want to specify the start and end time of the test, you have an option here
Once the Thread Group is configured add a Sampler called "HTTP request"



Provide the server name, port number, method etc


HTTP Request configuration
  • Server Name or IP - the server name or the IP address of the machine running the application being tested.
  • Port Number - the port number used by the web application
  • Protocol - the protocol used, either HTTP or HTTPS.
  • Method - the request method, either GET/POST/PUT or other options.
  • Path - the relative path to the page you want to hit
  • Follow Redirects - follows redirections sent by the Web application, if any.
  • Use KeepAlive - if checked, sends the Connection = Keep-Alive request header. By default, an HTTP 1.1 browser uses Keep-Alive as the value of the Connection header. Therefore, this checkbox should be checked.
  • Parameters - the list of parameters sent with this request. Use the Add and Delete buttons to add and remove parameters.
  • Send a file with a request - simulate a file upload to the Web application, good to test a large file upload through POST request scenario
  • Retrieve all images and Java Applets - download embedded content.
Add a couple of listeners "View results as Table" & Spline visualizer to see the load test results



Now save the project and run the Test, you will be seeing the samples in your configured listeners, here you can find the time taken for each thread sample hit and status of the request served by Server, number of bytes transfered and start time of the samples
Results in a Table


Result in Spline visualizer


Now fiddle with your code to tweak the performance.

Thursday, July 1, 2010

Windows could not start the Windows Process Activation Service service on Local Computer.

Got a hit from my IIS 7, which hosts Share Point 2010.World wide web publishing service refused to start as there is a dependency with Windows Process activation service. It just says

The World Wide Web Publishing Service service depends on the Windows Process Activation Service service which failed to start because of the following error: The system cannot find the file specified

Restarting WAS results in

"The Windows Process Activation Service service terminated with the following error:The system cannot find the file specified."



Fortunately Scott Hanselman's blog article comes to the rescue to identify the issue. Some of folders within c:\inetpub was missing and Scott taught the way to locate the problem using Process monitor.



Good to have an additional tool narrow down the issue.