Aug 18, 2015

Step by Step Guide to Create Provider Hosted App in Sharepoint 2013 Online with Azure Hosting Model- Part 4

This is a continuation to my previous post Step by Step Guide to Create Provider Hosted App in Sharepoint 2013 Online with Azure Hosting Model- Part 3


Publish the app in SharePoint On line site :


Right click on your appproject (MSPProviderHostedDemo) in visual studio and say publish.




Click on Edit and provide the Client and Client Secret (Which we generated in above steps).


Say Finish.

Then click on “Package the App” button. You will get a warning saying SP requires azure url as  https.

So change the url to https like below. 



Say Finish.

A App file is generated and the folder will be opened in windows explorer with the version number

path C:\Users\madpu02\Documents\Visual Studio 2013\Demos\MSPProviderHostedDemo\MSPProviderHostedDemo\bin\Debug\app.publish\1.0.0.0




Copy the app file and upload in AppsforSharepoint library in your SharePoint appcatalog site.

In my case here is the url 




Once upload is completed in appcatalog site, go to your sharepoint online site where you want to install and run this app.

 In my case url is like this https://pcmsp.sharepoint.com/sites/SPODev
Go to site contents à Add an App à Then our app should appears in the “apps you can add”section like below.



Click on App and Say Trust It



With this your app installtion is completed. You can see it in site contents tab like below.




Now click on the app, it should redirect to default.aspx page in our azure website like this.




The url looks like this , it contains the host sharepoint site url as a parameter for the the azure website url..


We Successfully Created and Published the Provider Hosted app in to Azure...!! Hope this post helps you guys...!!

- Purna


Aug 6, 2015

ASP.NET Site failed starting up, see full details for more info. System.Web.HttpException (0x80004005): Unrecognized configuration section log4net.

Guys,

If you are using log4net in your asp.net website, you may encounter the below error

System.Web.HttpException (0x80004005): Unrecognized configuration section log4net. (C:\Users\madpu02\Documents\My Web Sites\WebMatrixRemote\moresharepoints\web.config line 42) ---> System.Configuration.ConfigurationErrorsException: Unrecognized configuration section log4net. (C:\Users\madpu02\Documents\My Web Sites\WebMatrixRemote\moresharepoints\web.config line 42)
   at System.Web.HttpRuntime.HostingInit(HostingEnvironmentFlags hostingFlags, PolicyLevel policyLevel, Exception appDomainCreationException)
   at Microsoft.WebMatrix.Editor.CBMWrapper.HandleExceptionAndReturnEmptyArray(Exception ex, Boolean throwOnHttpException)
   at Microsoft.WebMatrix.Editor.CBMWrapper.GetReferences()
   at Microsoft.WebMatrix.Editor.Roslyn.ProjectSystemImpl.CbmAppDomainStarted(Object sender, EventArgs e)

The reason for this error is  the asp.net websites requires a log4net config section in web.config file.

Resolution : Add the log4net section in Config Sections of the webconfig .

 <configSections>
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>  
</configSections>


For Asp.Net WebApplications(not websites) this is not required.

Jul 19, 2015

How to Turnoff Notifications (Reminders) in SharePoint Online Sites :

Hi Guys,


Here is a small post on notifications in SharePoint online. As you know, when we log in to the SharePoint online portal, we observe (sometimes get irritated too with their creepy sound  J ) like this.


If you want to avoid these annoying notifications, do these below settings..
Click on Gear Symbol on Suit bar. Select Office 365 Settings


Select Notifications tab in the page



“Off” the notifications which you don’t want.

Hope this is helpful

Thanks
Purna

Jul 8, 2015

Search has encountered a problem that prevents results from being returned. If the issue persists, please contact your administrator.

Hi Guys,


Here I want to share the issues which I encountered while working with the search service application in SharePoint 2013

In this post I am going to deal with these two errors
  •   Search has encountered a problem that prevents results from being returned. If the issue persists, please contact your administrator.
  • The search request was unable to connect to the Search Service.

Error1: Search has encountered a problem that prevents results from being returned. If the issue persists, please contact your administrator.

I have configured the service application and created some content sources and used to get the results as expected. But somehow suddenly I got this below issue (im not sure on the root cause but expecting this is the issue with the patching on server)


When I searched in the 15 Hive logs with the above correlation id, I found this below information saying "Unable to Connect to Index System"

Failed to create session for index system: SPf48ba6ea0462: Microsoft.Ceres.SearchCore.Services.ContentRouter.ContentException: Unable to connect to index system SPf48ba6ea0462     at Microsoft.Ceres.SearchCore.ContentRouter.ContentRouter.VerifyIndexSystem(String indexSystem)     at Microsoft.Ceres.SearchCore.ContentRouter.ContentRouter.OpenSession(String indexSystem, Action`1 callback, IDictionary`2 defaultPolicy)     at Microsoft.Ceres.ContentEngine.Processing.Mars.MarsWriterProducer.GetSession(String indexSystem)    ------10      SharePoint Foundation                  Logging Correlation Data   xmnv   Medium   Site=/         6ac1179d-715f-606d-5c6c-42baed190a9f


I searched on internet and grabbed the info from different sites and came to know that, the issue the search index partition is degraded.

To resolve this, we need to reset the index of the search service application and do the full crawl of the content sources.


In my case, I have 2 search service applications, so I ran this command to find which is in degraded state

$ssappn = Get-SPEnterpriseSearchServiceApplication
Get-SPEnterpriseSearchStatus –SearchApplication $ssappn[0].Name
and then
Get-SPEnterpriseSearchStatus –SearchApplication $ssappn[1].Name

The second service application given me the status like degraded



So I went to central admin and  then opened the second search service application (which was degraded) and did the index reset as shown below( you can find a link in the quick launch called “Index Reset” in search administration page).




It takes some time. Once it is completed, do a full crawl of your content source.This may solves issue in some cases and gives you the results... But in my case I did not get the results. I encountered the same issue as previous.

So i decided to delete this corrupted search service application (as it is dev enviroment)  to avoid issues for my search application (the first one in above)

So i deleted this corrupted second service application and try to perform the search. But this time i got new error 

Error 2 : The search request was unable to connect to the Search Service


Cause for this is the proxy for search service application doesn’t exist in the farm. This is responsible for the communication between webpart and the service application

So to resolve this issue, we need to create a new proxy. Run these commands to create

$searchServiceApp = Get-SPEnterpriseSearchServiceApplication
New-SPEnterpriseSearchServiceApplicationProxy -SearchApplication $searchServiceApp



Now my results appeared  like charm :)




Hope this helps..

References :

May 25, 2015

SharePoint Online :This HTML cannot be inserted because you don't have access to add scriptable Web Parts in this site. Please contact your administrator if you think you should have rights to do so.



Hello,

Recently when i was working on one of the project requirements to hide quick launch items for a specific page (SharePoint Online) using  script editor webpart(Embed Code webpart) on to the page,  i got  the below error while injecting the script 


"This HTML cannot be inserted because you don't have access to add scriptable Web Parts in this site. Please contact your administrator if you think you should have rights to do so."



The reason for this is, by default the sharepoint sites  in online are configured to not allow to inject the scripts from UI. This has a setting at site administration . You can change the settings by following the below steps

Resolution :


In Custom Script Section select the option "Allow users to run Custom script on personal sites and selfservice created sites.."



Note : As mentioned in the screen, to apply these changes it may take 24 hrs.

Thanks
Purna

May 19, 2015

Chrome Control in Provider Hosted Apps to Navigate to SharePoint Site

Hi Guys,

In this post i am going to explain what is chrome control and how can we use it in our apps..

As you all know, basically there are two ways to host our apps..One is hosting in SharePoint(SharePoint-hosted) and other is in external systems/providers (also called as auto-hosted or provider-hosted.)

Basically when we host app in SharePoint, the app also gets the look and feel of SharePoint like menu and some other links which helps the user in going back to the SharePoint site. But when we host in external system, there would be no consistent look and feel like SharePoint. We will miss navigation and other short cut links to SharePoint site.


To overcome this problem, Microsoft provided a control called Chrome Control, which enables you to use the header style of a specific SharePoint site in our apps. This doesn't need any server library reference or custom tool, only reference of the SharePoint JavaScript library.

I have developed a provider hosted app with ACS model. And here is the landing page of the app, without chrome control

As you see here, there is no link to go back to sharepoint site from this app. Now here i am going to place chrome control in this page, which gives the links and navigation menus to host sharepoint site.


How to configure and use the chrome control?

To use chrome control in our app, we need these below libraries

  • jquery-1.9.1.js – can be loaded from cdn/filesystem
  • sp.ui.controls.js- load from layouts directory


Now add a div which has to hold the chrome control in your landing page of the app(usually default.aspx).This is the HTML body mockup with chrome control

<body style="display: none">
     <div id="chrome_ctrl_placeholder"></div>
    <div id="MainContent" style="background-color:yellow">
      <h1>Provider Hosted Sample using ACS</h1>
    </div>
</body>

Now using script, we will load chrome control in above div.


The script looks like this, replace head tag of your html with below one

<head>
    <title>Chrome control host page</title>
    <script src="//ajax.aspnetcdn.com/ajax/4.0/1/MicrosoftAjax.js" type="text/javascript"> </script>
    <script type="text/javascript" src="//ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.2.min.js">   </script>
    <%--<script type="text/javascript" src="demochrome.js"> </script>--%>
    <script type="text/javascript">
        "use strict";
        var hostweburl;
        $(document).ready(function () {
            hostweburl = decodeURIComponent(getQueryStringParameter("SPHostUrl")
            );
            var scriptbase = hostweburl + "/_layouts/15/";
            $.getScript(scriptbase + "SP.UI.Controls.js", renderChrome)
        });

        function chromeLoaded() {
            $("body").show();
        }

        function renderChrome() {
            var options = {                                          
                "appTitle": "Chrome control demo",
                "onCssLoaded": "chromeLoaded()",
            };
            var nav = new SP.UI.Controls.Navigation(
                                    "chrome_ctrl_placeholder",
                                    options);
            nav.setVisible(true);
        }


        function getQueryStringParameter(paramToRetrieve) {
            var params =
                document.URL.split("?")[1].split("&");
            var strParams = "";
            for (var i = 0; i < params.length; i = i + 1) {
                var singleParam = params[i].split("=");
                if (singleParam[0] == paramToRetrieve)
                    return singleParam[1];
            }
        }
    </script>
</head>
In the above script,

getQueryStringParameter : this function get the host web (sharepoint web) url from the appUrl
renderChrome : This function renders the chrome control in to the page .

In renderChrome function, we are creating a variable called 'options' which holds all the required options for the chrome control like the app title, link to other page etc. 

And we are creating a new object for navigation with the div(chrome_ctrl_placeholder) and the specified chrome control options and making it visible.

Now the apps landing page would look like below


For more information and the code , please follow this msdn link

Thanks,
Purna




Mar 30, 2015

Run as Different User in SharePoint Designer 2007

Hello Guys,

As all you know, sometimes the designer takes the domain logged in user credentials by default without prompting for credentials. And also when you try to open the site again, it takes these credentials by default and it won’t prompt for credentials. 

Initially , I have tried these below two options to resolve this, but no luck 

  • Changing the browser option from "Automatic Login Only in Intranet Zone "to "Prompt for name and Password" dint work. (in IE you can find @ Internet Options --> Security-->Custom Level)
  • Deletion of Designer Cache ( Here is the link to delete)


Here is the solution to this issue is, open the designer executable with different user, here are the steps

Go to the path
C:\Program Files (x86)\Microsoft Office\Office12

And select the SPDESIGN.EXE , and then select Shift+RightClick , then you can see the option ‘Run as Different User’ like this 



Hope it helps ...!!

Thanks
Purna