Thursday, July 21, 2016

Hide Pages link in SharePoint breadcrumb

Its possible to have a custom site map provider developed in C# and use it to hide pages link in the breadcrumb, but while looking for a rather simpler solution, I found out the blog post below which mentioned a much cleaner and less time consuming way of achieving similar result.

The trick is to add two breadcrumb controls in master page, one for path and another one for the leaf node like so:

<asp:SiteMapPath ID="bestpath" Runat="server"
        SiteMapProvider="GlobalNavSiteMapProvider"
        CssClass="ms-sitemapdirectional"
        NodeStyle-CssClass="ms-sitemapdirectional"
        RenderCurrentNodeAsLink="true"
    /> >
    <asp:SiteMapPath ID="bestsubpath" Runat="server"
        SiteMapProvider="SPContentMapProvider"
        CssClass="ms-sitemapdirectional"   
        NodeStyle-CssClass="ms-sitemapdirectional"
        RenderCurrentNodeAsLink="false"
        CurrentNodeStyle-CssClass="breadcrumbCurrent"
        ParentLevelsDisplayed="0"

    />

Tuesday, July 19, 2016

Replace SharePoint 2013 OOB search box with a custom search box

This is a frequent requirement in SharePoint branding projects. I have found that this blog page explains steps necessary to replace search box through Visual Studio solution.

https://spbreed.wordpress.com/2013/11/19/sharepoint-2013-basic-search-box-customization/

Tuesday, July 12, 2016

Custom media content type in MVC Web Api 2

The MVC Web Api is quite powerfull in that it enables us to develop REST web services, however one key factor of REST design principles is  hypermedia as the engine of application state.

To achieve this, a custom media formatter class must be defined in MVC web api 2 project and then add and object of this class to GlobalConfiguration.Configuration.Formatters collection.

An in depth article can be found at

http://www.tugberkugurlu.com/archive/creating-custom-csvmediatypeformatter-in-asp-net-web-api-for-comma-separated-values-csv-format


Rest API

I came across a very informative article about REST API goals design. It is definitely worth reading whole the article.

https://www.infoq.com/articles/subbu-allamaraju-rest

Thursday, July 7, 2016

Adding Nuget package to a project in Source Control

While trying to add a package to a project via Nuget I was consistently getting the error "Invalid file path". While looking at the output windows I realized that the underlying issue was Nuget package manager was not able to add package files to source control and hence the files were not available in current workspace. This issue was resolved by following these steps:


  1. Create a new project and don't add it to Source Control eg at C:\Temp\WebApplication1
  2. Add the same package in question to the new project eg. MyPackage
  3. Open solutions folder in windows explorer and navigate to packages subfoler eg at C:\Temp\WebApplication1\Packages
  4. Locate the package folder by its name and copy it eg. C:\Temp\WebApplication1\Packages\MyPackage.1.1.0
  5. Open the packages folder at our source control stored solution eg. C:\Work\MyCompanyWebsite\Packages
  6. Paste the copied package folder here eg. C:\Work\MyCompanyWebsite\Packages\MyPackage.1.1.0
  7. Open source control explorer in the solution where we want to add this package
  8. Right click in the right hand pane and select Add Items to Folder ...
  9. Add the newly copied folder to the source control
  10. Open Nuget package manager window, search for MyPackage  and install it.

Custom routing in MVC

The OOB routing module in MVC has somewhat rigid routing capabilities, an alternative can be Nuget package at https://www.nuget.org/packages/MvcCodeRouting/1.0.2 which enables routing based on namespaces.

Wednesday, July 6, 2016

Debug MVC routes with Route Debugger

There are two interesting utilities in Nuget Package manager, RouteDebugger and WebApiRouteDebugger. These are quite useful to check how paths are matched by routes.config file.

Tuesday, July 5, 2016

Regular Expressions

There are a couple of tools which are very helpful in building regular expressions quickly

http://www.ultrapico.com/expresso.htm
http://www.regular-expressions.info/reference.html

Get List of Partitioned Tables in SQL Server

Table partitions have lot of benefits, although they can not be used for direct query mode of the latest SSAS Tabular cubes. The script copied here displays a list of all partitioned tables in a database

select distinct t.name
from sys.partitions p
inner join sys.tables t
on p.object_id = t.object_id
where p.partition_number <> 1
Copied from http://dba.stackexchange.com/questions/14996/how-do-i-get-a-list-of-all-the-partitioned-tables-in-my-database

Get List of Partitioned Tables in SQL Server

Table partitions have lot of benefits, although they can not be used for direct query mode of the latest SSAS Tabular cubes. The script copied here displays a list of all partitioned tables in a database

select distinct t.name
from sys.partitions p
inner join sys.tables t
on p.object_id = t.object_id
where p.partition_number <> 1
Copied from http://dba.stackexchange.com/questions/14996/how-do-i-get-a-list-of-all-the-partitioned-tables-in-my-database

c# httpclient The remote certificate is invalid according to the validation procedure: RemoteCertificateNameMismatch

 If we get this error while trying to get http reponse using HttpClient object, it could mean that certificate validation fails for the remo...