Tuesday, September 9, 2014

Use NuGet with SharePoint

Recently, while working on creating some custom features for SharePoint 2013, I got a bit of frustration trying to make a NuGet package work with SharePoint.
While the Nuget package was installed and didn't give any error in the code, at run time it was either not working at all but not showing any error, or giving a missing assembly error.
I, then found out that it was because the package created by the NuGet manager was not linked to the package that is created with the WSP and I had to add the library reference manually.
Here's how:

  1. Add the NuGet package you wish to use:

        


  2. You will notice that the dll is added to your references and is also added to the package


  3. That, however, will not be added to the SharePoint package, so let's add it manually





    In the popup Window, click the "Browse" button and make sure you browse to the current project, select the right package and add the right assembly.  














  4. And, Finally save the change you just made


  5. From this point on, the NuGet Package should work with no issue in your SharePoint project.

Hope this was helpful.

Friday, February 15, 2013

Allow anonymous access to SharePoint application pages in the _layouts directory

Often times, you need to add your own custom application pages (aspx) to SharePoint, which are deployed to the ‘_layouts’ directory. These types of pages could consist of a custom login page, maintenance pages, or even complete web applications that you’ll have live in SharePoint. But what if your web application has an authentication provider set up, such as Claims or Windows? In this article, I’ll show you how easy it is to allow anonymous access to these pages without forcing a user to log in.

Create the project

  1. In Visual Studio 2010, create a new “Empty SharePoint Project” and name it “MyAnonymousWebPages”.
    Click OK
  2. Enter your SharePoint site
  3. Select “Deploy as a farm solution”

Adding the custom Pages

Next, we need to map the ‘layouts’ directory to our project, so our files are deployed
there.
  1. Right click on the project name ‘MyAnonymousWebPages’ > Add > SharePoint “Layouts”
    Mapped Folder
  2. SharePoint will automatically add a folder under ‘layouts’ with the name of our
    project. Right click on this folder >Add > New Item > Application Page
  3. Name the page “HelloWorld.aspx”
  4. Your project should now look like this:

Allowing anonymous access

So far, we haven’t done anything special. The steps we’ve taken is the basic approach
to adding custom application pages. In the following steps, we will inherit from “UnsecuredLayoutsPageBase”. This is a base class for application pages that do not require the user to have any permissions.
  1. Open up HelloWorld.aspx.cs
  2. By default, the page is inherited from “LayoutsPageBase”. Change the inheritance
    from “LayoutsPageBase” to “UnsecuredLayoutsPageBase”. 
    public partial class HelloWorld : UnsecuredLayoutsPageBase
  3. Next, we need to override a property of the UnsecuredLayoutsPageBase, to allow the
    anonymous access. Be sure to change the ‘getter’ to return true 
    protected override bool AllowAnonymousAccess { get { return true; } }
  4. Add some content to your markup in the ‘PlaceHolderMain’

Deploy the solution

  1. Right click on your project name, and select ‘Deploy’
  2. Once deployment is complete, browse to your page by navigating to
    http://{yourSharePointUrl}/_layouts/MyAnonymousWebPages/HelloWorld.aspx
  3. See your custom page, like below (notice, by default, the ApplicationPage template
    in Visual Studio is designed to automatically inherit from the master page. You
    could instead replace the markup with markup from a standard aspx page template). 










Huge thanks to Tim Gabrhel for the wonderful information

Friday, November 16, 2012

SharePoint 2010, server 2012 and Powershell 3: Microsoft SharePoint is not supported with version 4.0.30319.17626 of the Microsoft .Net Runtime

If you are running SharePoint 2010 on a Server 2012 OS be aware of the current compatibilty issue that is identified with SharePoint Powershell and Powershell 3.

In order to make use of the powerfull powershell commands, all you need to do is switch the powershell version back to version 2.
Note: This will not uninstall version 3, it will simply launch a new powershell instance that uses version 2.

There I fixed it!

Information from Tom Van Gaever

Tuesday, August 21, 2012

PowerShell Commands To List SharePoint Features


The more I work with SharePoint 2010 the more I am starting to love PowerShell. My scripting skills are pretty basic (!) but here are a couple of useful little snippets to get back some information from a site that previously I would have spent a while going through the UI or SharePoint Root – mainly as a reminder for myself!

List all installed features on the farm
It’s really straight forward using the Get-SPFeature command to return all installed features. To provide a little more readability to the output it can be sorted as follows:

By feature display name alphabetically,

Get-SPFeature | Sort -Property DisplayName

By feature ID,

Get-SPFeature | Sort -Property Id

By feature display name alphabetically and grouped by scope,

Get-SPFeature | Sort -Property Scope,DisplayName | FT -GroupBy Scope DisplayName,Id

And to write this to a file to allow for viewing in Notepad, Excel etc,

Get-SPFeature | Sort -Property Scope,DisplayName | FT -GroupBy Scope DisplayName,Id > c:\AllInstalledFeatures.txt


List all activated site scoped features
Especially in the case of hidden features it’s sometimes necessary to track down if a feature is active on a site collection. Here’s a quick way of seeing which features are activated for an SPSite:

Get-SPFeature -Site http://sitecollectionurl | Sort DisplayName | FT DisplayName,Id

List all activated web scoped features
And only slightly modified from the Get-Help Get-SPFeature -examples text, here is a command to list all web activated featres for a site collection:

Get-SPSite http://sitecollectionurl | Get-SPWeb -Limit ALL | %{ Get-SPFeature -Web $_ } | Sort DisplayName -Unique | FT DisplayName,Id

Information given by Glyn Clough

Thursday, July 12, 2012

Error message: (provider: Shared Memory Provider, error: 0 - No process is on the other end of the pipe.)

This is the common error when we are working with sql server.It will occur while establishing a connection to sqlserver.In this post i will explain how to resolve network and remote connection error.First we need to check the given data source name is correct or not in connection string.The TCP/IP protocol or in some instance the Named Pipes protocol should be enable to made such type connection.The following steps will describe how to enable TCP/IP or Named Pipes protocol in sql server configuration manager
Go To-->Configuration Tools folder which is in MS Sql Server 2008 folder in start menu
2.Select server Network configuration-->click on protocols for SQLEXPRESS.
Then we can see the protocols at Right side panel.By default the TCP/IP status is in disable mode.So we need to change status to enable

 3.Select SQL Server Services --> right-click on your instance of SQLEXPRESS / SQLServer and click "restart"

Reference

Thursday, September 15, 2011

Where is “Save As Template” in SharePoint 2010?

When publishing feature is enabled in SharePoint 2010, the “Save As Template” option would magically disappear. A quick solution to this is by manually using the URL /_layouts/SaveTmpl.aspx

Info from here

Thursday, August 18, 2011

Hide First Tab in SharePoint 2010 Navigation

I created a blog post on this for SharePoint 2007 HERE: But SharePoint 2010 is a bit more complex. Since it uses UL’s and Li’s for it’s navigation it is a bit harder to hide just one element.
image
You will notice that the Home tab actually is the first node and then has a child UL which represents the rest of the navigation Items. So the approach is to hide the first <li> <a> (display: none) and then simply just use (display:block ) to show the hidden <ul> <li> <a> tags.
Here is the CSS you could use to hide just the first node (home) tab in a SharePoint 2010 application:
.s4-tn li.static > a{
display: none !important;
}
.s4-tn li.static > ul a{
display: block !important;
}

image
Enjoy!

Information given by Erik Swenson