SharePoint passing the wrong SPAppWebUrl

I’m seeing something weird happening in my provider hosted app. When deploying the app via Visual Studio, the output says:

App was installed at

Okay, fine. So now I open up my SharePoint dev site, click on the app and my app is opened. But… the JSOM calls I put in there are failing. I started bugfixing and found out that the URL to my app looks like this:

Let’s take a closer look at that SPAppWebUrl querystring parameter and decode it:

Hey… huh… it’s a different one as where the app was originally deployed to? When browsing it, SharePoint says:

Cannot find site for request ‘‘.

Which seems legit since the app was deployed somewhere else.

So the question now is; why the heck would it include a different URL in the querystring, pointing to a site which does not exist?

Update: from the URL to the app, I got the app instance id. That can be used to retrieve the app instance using Get-SPAppInstance in Powershell. The instance has a AppWebFullUrl property which points to the correct URL (the one from VisualStudio).

Update 2: I removed and rebuilt my developer site, which didn’t help. It seems the URL being used for the appweb changed, but it still point to a site which doesn’t. I also tried a simple app from the MSDN examples, which behaves exactly the same. I then tried reprovisioning the subscription and app management service applications (removing the databases), which also did not make any difference.

How to store some hidden files at SharePoint via Provider hosted SharePoint app

We would need to build a solution to allow some users who doesn’t have permission on a certain library to view the document in browser only, so we are thinking to go with provider hosted app with app parts. So those users without permission would view the protected document via app parts. To be able to show the document for online view only, we need to generate some intermediate files based on document at the existing document library (remote web would read this document with app only access token) and we would like to cache it back to SharePoint. I am thinking that we would create a hidden folder under that particular library or a hidden library to store those files. After some search on internet, I didn’t find out if I could do this or not. It would be appreciated if you should shed some lights here.

Sharepoint-hosted app on-premise 2013

We have been developing SharePoint-hosted apps for SP online with great success, but seems like developing SharePoint-hosted apps for the on-premise 2013 is not so intuitive process.


  1. As a rule of thumb, should we NOT create sharepoint-hosted apps on the on-premise?
  2. For every new deployment version, unless users go to Site Content and Trust the app, it wont appear on the with X-Frame-Option = SAME ORIGIN error. Note that all of my ClientWebParts include the AllowFraming tag. We also use plenty of the AppContextSite Lists.
    Isn’t there any way to set my app as trusted, so that any user visiting the page hosting the AppPart, be able to see the content of my app?

    • None of this issues exist on the online version and i was wondering if the sharepoint-hosted apps are not meant to be deployed on the on-premise.

** This thread is based on another thread i raised recently, but I thought to create a new one for narrowing the problems I have! Do not down-vote for duplication !
Sharepoint-hoted apps for Sharepoint 2013 – X-Frame-Options error

UPDATE 1: point 2 revised

In point 2 I mentioned that my app requires Trust from all users. The correct is that the app requires login from all users visiting Site Contents before they can view it on the page. Here is the revised point 2.

  1. For every new deployment version, unless users go to Site Content open the app and insert their credentials, it wont appear on the page with X-Frame-Option = SAMEORIGIN error. Note that all of my ClientWebParts include the AllowFraming tag. We also use plenty of the AppContextSite Lists.
    Isn’t there any way to login without going to the Site Contents or event better to use the Site credentials and login directly without extra effort from the user?

Getting DNS error when accessing app from app catalog site

I wanted to create an app which will access data across site collections so I downloaded code sample from here.

I published this VS solution so I got app package in solution BIN folder. I uploaded that app on my app catalog site and then add this app in same app catalog site so it’s showing in “Site contents”.

I clicked on the app which redirected me to app site but I didn’t see it, instead I got below error on the page

[Fiddler] DNS Lookup for “app-1be620271cad00.spapp” failed. System.Net.Sockets.SocketException The requested name is valid, but no data of the requested type was found

BTW Fiddler is installed on my DEV machine.

This error is saying something about the DNS settings so I googled and found below articles which says I need to setup some DNS related stuff, but how can I do this?

I don’t have any DNS Manager on my DEV machine? Is there any other way to solve this?

Include other apps when creating a Site collection using CSOM

I have created a color theme provider hosted apps which includes an app part.

Now I am creating another provider hosted apps, which creates a site collection using CSOM. I want to make sure the color theme app is included on the news site collections created by my app by default.

Event receiver not firing Document Library

I have a local development environment in my VM.(SharePoint server 2013 SP1,Visual Studio Ultimate 2013-update3). I’m trying to add an event receiver to a document library on ItemDeleting. Deleting a document in the document library should add an item to my custom List ‘Log’. Here is my code:


  using System;
  using System.Security.Permissions;
  using Microsoft.SharePoint;
  using Microsoft.SharePoint.Utilities;
  using Microsoft.SharePoint.Workflow;

  namespace SharePointProject1.EventReceiver1
    public class EventReceiver1 : SPItemEventReceiver

    public override void ItemDeleting(SPItemEventProperties properties)
        using (SPWeb web = properties.OpenWeb())
                SPList list = web.Lists["Log"];
                SPListItem newItem = list.Items.Add();
                newItem["Title"] = properties.ListItem.Name;
                newItem["DateAndTime"] = System.DateTime.Now;
                newItem["Action"] = "Item Deleted";
            catch (Exception ex)
                throw ex;


     <?xml version="1.0" encoding="utf-8"?>
      <Elements xmlns="">
       <!-- <Receivers ListTemplateId="101" > -->
       <Receivers ListUrl ="Doclib"


      <?xml version="1.0" encoding="utf-8" ?>
       <Feature xmlns="">

I deployed the solution on the SP site and activated the feature.

So I have two questions:

  1. When I use the code: ListTemplateId=”101″ , I do not get an error, But the event receiver is not firing. When I delete the “Log” list is not updated. Am I missing something?
  2. If I give the Document library name in the ListUrl, I get the following error:

“An error occurred in deployment step ‘Activate Features’: The list
“Doclib” doesn’t exist. Please fix the ListUrl attribute.”

Please advise on the right approach.
Why is my event receiver not firing?

Client rendering not working in IE 8

I have a SharePoint 2013 SP1.
I have one app fields on the form. This field uses the client rendering.
For all browsers except IE 8, everything works correctly.
IE 8 is supported (, but happening here strange things.

  • For all mandatory fields not generated input
  • For all non-text field (number, url, …) is not generated input
  • When saving a item, then is generated js error in clientforms.js

Print screens:

Any suggestions? Does somone know whether MS announced patch dealing with this issues?

There are no addresses available for this application Creating setting service application

I have the following script to create the subscription settings service application, however it fails at this line:

  Set-SPAppSiteSubscriptionName -Name $AppPrefix -Confirm:$false

The error is:

There are no addresses available for this application

My script is this one:

#This service application provides multi-tenancy features as well as the ability to run apps.
#Read more:
$ServiceApplicationName = "Microsoft SharePoint Foundation Subscription Settings Service Application"
$ServiceName = "Microsoft SharePoint Foundation Subscription Settings Service"
$MachinesToActivate = @("WIN-xx")
$DatabaseName = "spServiceApp-Subscription"
$spAppPoolName = "Subscription Settings Service Application Pool Account"
$spAppPoolAcc = "WINGTIPspAppPool"
$AppDomain = ""
$AppPrefix = "tenant"

Write-Host "SharePoint 2013 - '$ServiceApplicationName'..."

#Allows to use SharePoint cmdlets from inside the Windows PowerShell command window
Add-PsSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue | Out-Null
Start-SPAssignment -Global | Out-Null

#Get default SQL server
$DatabaseServer = (Get-SPDatabase | ? { $_.Type -eq "Configuration Database" }).NormalizedDataSource

    #Check for existing service application and proxy
    $ExistingServiceApp = Get-SPServiceApplication | where-object {$_.Name -eq $ServiceApplicationName}

    if ($ExistingServiceApp -eq $null)
        Write-Host " - Creating '$ServiceApplicationName'"

        #Check if application pool already exist, if not create it
        $spManagedAccount = Get-SPManagedAccount -Identity $spAppPoolAcc
        $ApplicationPool = Get-SPServiceApplicationPool -Identity $spAppPoolName -ErrorAction SilentlyContinue
        if ($ApplicationPool -eq $null)
            New-SPServiceApplicationPool -Name $spAppPoolName -Account $spManagedAccount | Out-Null
            Set-SPServiceApplicationPool $ApplicationPool -Account $spManagedAccount | Out-Null

        $SA = New-SPSubscriptionSettingsServiceApplication -Name $ServiceApplicationName -ApplicationPool $spAppPoolName -DatabaseServer $DatabaseServer -DatabaseName $DatabaseName

        #Create Service Application Proxy
        Write-Host " - Creating '$ServiceApplicationName' proxy"
        New-SPSubscriptionSettingsServiceApplicationProxy -ServiceApplication $SA | Out-Null

        #Start service instances
        Write-Host " - Starting service instance"
        foreach ($machine in $MachinesToActivate) 
            #Gets the service to determine its status
            $service = $(Get-SPServiceInstance | where {$_.TypeName -match $ServiceName} | where {$_.Server -match "SPServer Name="+$machine})

            If ($service.Status -eq "Disabled") 
                Write-Host " - Starting" $service.ID "on $machine"
                Start-SPServiceInstance -Identity $service.ID | Out-Null

        #Setting App Management Properties
        Write-Host " - Setting App Management Properties"             
        Set-SPAppDomain -appdomain $AppDomain
        Set-SPAppSiteSubscriptionName -Name $AppPrefix -Confirm:$false

        Write-Host " - Done creating '$ServiceApplicationName'.`n"
        #Write-Host " - '$ServiceApplicationName' already exists."
        write-host " - Removing '$ServiceApplicationName'..."
        Remove-SPServiceApplication $ExistingServiceApp -removedata -Confirm:$false

        #Proxy is NOT automatically deleted
        $ExistingServiceAppProxy = Get-SPServiceApplicationProxy | where-object {$_.Name -eq "$ServiceApplicationName Proxy"}
        if ($ExistingServiceAppProxy -ne $null)
            write-host " - Removing '$ServiceApplicationName proxy'..."
            Remove-SPServiceApplicationProxy $ExistingServiceAppProxy -Confirm:$false
        write-host " - Stopping service instance..."
        Get-SPServiceInstance | where-object {$_.TypeName -eq $ServiceName} | Stop-SPServiceInstance -Confirm:$false | Out-Null
catch { write-Output $_ }

Stop-SPAssignment -Global | Out-Null
cmd.exe /c pause

SharePoint 2013 apps Permission policies

As I understand there can be a “User+App” and “App” only policy permissions in SharePoint apps. The SharePoint hosted app cannot use the App-only policy. So here is the doubt I have. Suppose I have a SharePoint hosted app which has modify permissions on a list in the HOST web. The app adds new items/modifies items in the list. Now a user accessing the APP has READ permission on the list in host web. In this case both, the app and user identities will be sent during the add/modify operation.

So does this mean that the app wont be able to add/modify list items because the user has READ only permissions on the list ?

Also, can we say that the APP-only policy is something which can be used as Elevating privilages to perform operations that a user cannot perform ?

Cross Domain OData filter on title breaking with & in the field

I am attempting to do a cross domain request from my app.

Document Library Title name is !@$^&()-+={[}]|;MEEPBEEP with the Server URL of MEEPBEEP

In accessing the host web in my request executor my function is as follows

function findDL() {
var executor;
var dfd = new jQuery.Deferred();
executor = new SP.RequestExecutor(appweburl);
    url: appweburl + "/_api/SP.AppContextSite(@target)/Web/Lists" +
        "?@target='" + hostweburl + "'" +
        "&$select=Id, Title&$top=5000&$filter=Title eq '" + ListInfo.oldName + "'",
    type: "GET",
    dataType: "json",
    headers: {
        Accept: "application/json;odata=verbose"
    success: successHandler(dfd),
    error: errorHandler(dfd)
return dfd;

function successHandler(dfd, data) {
return dfd.resolve;
function errorHandler(dfd, data, errorCode, errorMessage) {
return dfd.reject;

When I attempt this without special character it works fine but when I add in the & my request 404 on me.

To continue testing I opened up postman and attempted to find the list by using

hostWEB/_api/web/lists?$filter=Title eq ' listname'

and without special characters I am able to get the list information.

When I search for a list name with a & in it It 404 on me. When I change the & to %26
I get the following JSON returned to me

    "d": {
        "results": []

So clearly SharePoint can find the list but it’s not returning any information to me. I have add the OData Select Statements to select the columns I wish to see but I still get a blank JSON result.

An attempt with GetByTitle returns the list information. Sadly I don’t believe I can use this endpoint as it is a cross domain request.

If I am unable to fix this issue I simply make a workflow that will use the GetByTitle but I would rather not lose the code I have worked one.

The following request worked:

var executor;
var dfd = new jQuery.Deferred();
executor = new SP.RequestExecutor(appweburl);
    url: appweburl + "/_api/SP.AppContextSite(@target)/Web/Lists/GetByTitle('" + ListInfo.oldName + "')?@target='" + encodeURIComponent(hostweburl) + "'",
    type: "GET",
    dataType: "json",
    headers: {
        Accept: "application/json;odata=verbose"
    success: successHandler(dfd),
    error: errorHandler(dfd)
return dfd;

Still I am left wondering why the OData Query gives me a blank result set. While the fix does seem to work, It leaves me to wonder if this is a bug with SharePoint OData Filtering options.

Question and Answer is proudly powered by WordPress.
Theme "The Fundamentals of Graphic Design" by Arjuna
Icons by FamFamFam