Skip to main content

Posts

Showing posts from April, 2013

Create a Web Part Page Programmatically

When creating SharePoint Solutions we need to deploy Web part pages with the solution. I'm sure most of us deploy pages as a module. But we are copying aspx page from some ware else and include it to module . (Visual studio does not allow to create web part aspx pages in SharePoint Solutions)  So I think it is good to use a method to create web part pages rather than copying from somewhere else and put it to the solution. Using below method you can add web part page to document library with  specified template. of cause you can add custom template ; in that case you can deploy custom template first and use the following method to create a web part page. First you need to generate the XML for add Web Part Page private string GetCreateWebPartPage(String list, string pageTitle, int layoutTemplate) { const string newItemTemplate = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<Batch>"

How to Check Bit is Set (Compare to Bits)

I had a recent requirement to check whether bit is set looking another bit. But then i found; it is easy to compare integer values it self rather than converting to bit arrays. public bool isBitSet( int value , int checkBit) { return (value & checkBit) == checkBit; } Ex: I want to check number 8 is set in 6164 , You can get it by isBitSet(6164,8)

Access is Denied when submitting Task Job to Azure Media Services

When submitting Job task in Azure media service it is giving error “ Access Denied ”. ITask task = job.Tasks.AddNew( "My task" ,processor, "H264 Broadband 720p" ,TaskOptions.ProtectedConfiguration); // Specify the input asset to be encoded. task.InputAssets.Add(asset); task.OutputAssets.AddNew( "Output asset" ,AssetCreationOptions.None); // Launch the job. job.Submit(); This is the code segment I have used. This is working in my local machine but I published to Cloud Web Site it is giving access denied error. I found that the  TaskOptions.ProtectedConfiguration caused this error. When you use this option it is accessing client machine certificate store. Since running context does not have sufficient permission; causing  access denied error. So change the TaskOptions.None . it will work.

How to Get SharePoint Client Context in SharePoint Apps (Provider Hosted / SharePoint Access ) in CSOM (Client Side Object Model)

First step of the of the app development is to correctly get the access to SharePoint client context. I have struggling with develop a simple model to initialize the SharePoint Client context. Most of the App development include ASP Master pages. So I need to figure out a working model for app development. First you need to know how SharePoint offer the contextString . contextString Offers when SharePoint is getting redirect from appredirect.aspx url. Ex :- https://rajee.sharepoint.com/_layouts/15/appredirect.aspx?instance_id={B0D5D768-303F-4AE7-A4D3-F94B687C6AB3 that point we need to capture the contextString and generate either AccessToken or RefreshToken and save it for access the SharePoint  Client Context in later time. other wise it will result in generating the  error The parameter 'token' cannot be a null or empty string (This is nasty error which drove me crazy) Normally AccessToken is valid for 12 hours and RefreshToken is valid for 6 months. In my approach I

Understanding Asure Media Service Core Components

Azure media service contains few components. Lets look as abstract. You can find your existing components and there status by navigating to LINK RESOURCES in Azure Media Service. Storage Account Storage account is capable of storing media files that is uploaded to azure media service. Storage account is a Shared Resource which we can use for store other items through out the cloud. Storage Account is mapped to Cloud Storage.  You need to specify a existing account or you can create a new storage account when you are creating a Azure Media Service. Single storage unit is called as Asset in the Azure Media Service . In the same time Asset is also refer as container in the Azure Storage context . Asset / Container is a group which can contains files. When you go to Azure Media service you can view existing assets by navigating to CONTENT link in the azure. Most people misunderstand Asset and Asset files. Though media service shows a publish URL; it doesn’t mean that you can v

How To Access Server.MapPath in a Class that is not inside Web Project

In My case I have decoupled WCF Class Libraries and WCF Host in to two separate projects.  Then i need to get the Server.MapPath in a class library. So I have add the Reference to System.web   Since I'm using 4.5 dll is available on C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Web.dll HttpContext.Current.Server.MapPath( "~/App_Data/MediaPackager_MP4ToSmooth.xml" )

Request format is unrecognized for URL unexpectedly ending in

This error occurred to me when I try to call web service (asmx) from SharePoint provider hosted app. asmx is written to retrieve some list data from SharePoint app host web. I found that this error occurs because of missing configuration in the web.config. < system.web > < webServices > < protocols > < add name ="HttpGet" /> < add name ="HttpPost" /> </ protocols > </ webServices > </ system.web >