"The day you stop learning SharePoint is the day you stop using it."

Error "Updates are currently disallowed in GET requests. To allow updates on a GET, set the 'AllowUnsafeUpdates' property on SPWeb".

You may encounter an exception when accessing General Settings or Resource Throttling for a web application in Central Administration:












Solution:
Open SharePoint Management Shell and execute the below commands:

$w = get-spwebapplication http://<web application url>
$w.HttpThrottleSettings
$w.Update()
Share:

How to debug Windows Service in Visual Studio 2010

Most of the developers are unaware of the Visual Studio capability to debug Windows Service. On most of the blogs and forums I found common solutions speaking about attaching a debugger/process to the Windows Service.

While working on a SharePoint project my team came across a requirement to develop a Windows Service that consumes a SharePoint Web Service “Lists.asmx”. This was basically required to access the SharePoint list and its items via Windows Service.


As Windows Service does not have an UI, it’s a bit tricky to debug it. In this article I have explained how you can debug a Windows Service in Visual Studio 2010.


Steps:
Right click on the method that you want to debug and select Create Unit Test.
This will automatically create a Test Project in the solution explorer. Open the UnitTest1.cs and have a look at the code. This code can be manually developed but if Visual Studio can do it for you at a click of a button, it’s great! You may save your precious time for development, isn’t it?

Code Snippet generated by Visual Studio 2010 in UnitTest1.cs file:

using System;
using ServiceToUpdateList;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace TestProject1
{
    [TestClass()]
    public class Service1Test
    {
        private TestContext testContextInstance;
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes

        #endregion

        [TestMethod()]
        public void ReadingFromEmployeeDetailsListTest()
        {
Service1 target = new Service1 ();                 target.ReadEmployeeDetails ();          
        }

Service1 is my class name and ReadEmployeeDetails is my function name that I want to debug.

Attach breakpoint in your code file. Build your solution and click on Debug Tests in Current Context icon on the Test Tools toolbar. This will execute your code in debug mode in Visual Studio IDE.

Ensure that Test Tools is displayed on the toolbar, if not displayed go to View Menu -> Toolbars -> Test Tools.

Note: If you have created an App.config file in Windows Service then that App.config file must be copied to the Test Project as well. Because the Test Project will not read App.config of your Service Project, instead it reads from the Test Project.
Share:

Customizing Refinement Panel

To customize Refinement Panel you need to edit the xml file stored in Filter Category Definition. Before performing the above steps make sure that you have created a new Managed Property in Metadata Properties (to the left panel) of Search Administration and mapped to the crawled property.










Perform a Full Crawl and then perform the below given steps.

1. Right click the Refinement Panel web part and select Edit Web Part.
2. Click on Refinement Option and uncheck ‘Use Default Configuration’ check box. 
3. Select Filter Category Definition box in Refinement Option to open the text editor.
4. Copy the entire contents of the text editor and save into a Notepad as an XML file.
5. Open the XML file in Visual Studio and add the following tag in the file.

<Category Title="Your Filter Category Name"   
Description="This category is about….."    Type="Microsoft.Office.Server.Search.WebControls.ManagedPropertyFilterGenerator”
MetadataThreshold="5"   
NumberOfFiltersToDisplay="4"   
MaxNumberOfFilters="20"   
SortBy="Frequency"   
SortByForMoreFilters="Name"   
SortDirection="Descending"   
SortDirectionForMoreFilters="Ascending"   
ShowMoreLink="True"   
MappedProperty="MappedPropertyName"   
MoreLinkText="show more"   
LessLinkText="show fewer"/>


6. Save the file.
7. Copy the entire content of the saved XML file and replace with the original file in the File Category Definition.
8. Click on Apply button and then click on OK button.

      Below image is an example of custom filter category added in Refinement Panel XML file.


Share:

SharePoint Server 2010 Versions

There are four versions of SharePoint Server 2010:

>> SharePoint Server 2010 Enterprise Client Access License features
For organizations looking to expand their business collaboration platform to enable advanced scenarios. Use the Enterprise capabilities of SharePoint to fully interoperate with external line-of-business applications, Web services, and Microsoft Office client applications; make better decisions with rich data visualization, dashboards, and advanced analytics; and build robust forms and workflow-based solutions.

>> SharePoint Server 2010 for Internet Sites, Enterprise
For organizations looking to create customer-facing public internet sites and private extranets using the full enterprise capabilities of SharePoint. This provides full SharePoint Enterprise functionality and no other technical limits.

>> SharePoint Server 2010 Standard Client Access License features

For organizations looking to deploy a business collaboration platform across all types of content. Use the core capabilities of SharePoint to manage content and business processes, find and share information and expertise, and simplify how people work together across organizational boundaries.

>> SharePoint Server 2010 for Internet Sites, Standard
For small and mid-sized organizations looking to create public Internet sites or basic extranets using the Standard features of SharePoint Server 2010.
Share:

Return the Current Site in an Event Receiver; the site in which event occurred.

In an ItemUpdated Event Receiver we were accessing two custom lists for reading values and for that we required to return the current site in which the event occured.
Simply writing SPSite mySite = new SPSite("http://yoursitename"); does not make sense. Because you might don’t know where you need to deploy the Event Receiver, hence hard-coding the Site URL is a bad practice. The below code shows how to return current site URL.

namespace ItemUpdateFeatureReceiver
{
 public class Class1 : SPItemEventReceiver
 {
  private SPWeb _web;

  public SPWeb myWeb
  {
    get
    {
      return _web;
    }
    set
    {
      _web = value;
    }
  }

//Property that returns a custom list named “Document Type”
public SPList CustomList1
{
  get
  {
    SPList myList = myWeb.Lists["Document Type"];
    return myList;
  }
}

//Property that returns a custom list named “Document Sub-Type”
public SPList CustomList2
{
  get
  {
    SPList myList = myWeb.Lists["Document Sub-Type"];
    return myList;
  }
}


public override void ItemUpdated(SPItemEventProperties properties)
{
  //Returns the current site in which event occured
 
  myWeb = properties.OpenWeb();
  
  //your code
}
Share:

SharePoint-StackExchange Moderator

Author's Profile

My photo
India
A SharePoint Enthusiast working as a Lead Solution Architect for an IT Software & Consulting Company in Mumbai. I believe in giving back to the community through which I also learn and develop and eventually grow as an individual and professional. This blog is a small contribution to the community where I live in and may help someone who is seeking knowledge like me.

Popular Posts

Powered by Blogger.

Contact Form

Name

Email *

Message *

Total Pageviews