Provider-hosted apps - options to create
Just for self learning purpose, I want to create few provider-hosted apps, but I don't have any subscription for windows azure service.
I have only trial subscription of office 365.
My question is can I create provider hosted apps without any subscription for azure service (with the help of office 365 trial)?
Is there any free trial available to develop this, which doesn't need any credit card?
Since this is very important for me can any one experienced same situation reply to this question?
Hi,
According to your description, my understanding is that you want to get current logged in user in the Provider hosted app.
Something needs to clarify:
1. Does the two server exist in the same domain ?
2. Does the both server use the same user credential ?
3. Which error did it throw, would you please share it ?
In the Client Object Model, I suggest you can Token Helper to get the ClientContext in Provider hosted app.
Here are some detailed code demos for your reference:
How to: Create a basic provider-hosted app for SharePoint
How to Get SharePoint Client Context in SharePoint Apps (Provider Hosted / SharePoint Access ) in CSOM (Client Side Object Model)
Thanks
Best Regards
TechNet Community Support
Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
[email protected]
Similar Messages
-
Hi,
I am creating provider hosted app in visual studio 2012 using app scoped external content type having OData with Northwind url
App manifest start page url :
ODataNewAppWeb/Pages/Default.aspx
In XML it is:
<StartPage>~remoteAppUrl/Pages/Default.aspx</StartPage>
When i am deploying app pressing F5 the app gets deployed successfully....
Now i am changing my start page url in Appmanifest like this:
ODataNewApp/Lists/Employees
In XML it looks like:
StartPage>~appWebUrl/Lists/Employees</StartPage>
When i am deploying app pressing F5 the app..
Getting register SOD error.....
I have followed all the steps like:
1)Creating app domain
2)Starting all the required services
3)Creating root site collection
But still no success.. Please help me on this.... I am struggling with this from two weeks...Have you set up a wildcard DNS entry for the spapps.com domain?
Also if you're trying to connect from the server you might be hitting loop back check issues. -
Creating High trust provider hosted app in SharePoint online
Hi,
I need to create high trust provider hosted app for SharePoint Online. provider hosted would be not going to host in Azure but it will be some where else.
some kindly provide step by step that how to create High trust app for SharePoint online but not for SharePoint 2013.
Kapscheck this link
http://msdn.microsoft.com/en-us/library/office/fp179901(v=office.15).aspx#Intro
A high-trust app for SharePoint is is primarily intended for use in an on-premises environment. The high-trust
app cannot be installed to Microsoft SharePoint Online, and the remote components are typically installed on premises, too, within the corporate firewall. Thus, the instances of the app for SharePoint are specific to each individual company.
Kind Regards, John Naguib Technical Consultant/Architect MCITP, MCPD, MCTS, MCT, TOGAF 9 Foundation -
Unable to deploy the provider hosted app on sharepoint server !!!
Hello,
I have simply created the provider hosted app by assigning the issuer ID !
Now, the SharePoint version of the app project is set as SharePoint Online.
However, when I deploy this project to SharePoint site, it shows following error :
Unknown SharePoint version: 16.0
In order to resolve this I changed the SharePoint version as SharePoint 2013
of the app project.
Though , I am getting following error on deployment:
The target version of the SharePoint site is 15.0.4569.1000, which is lower than the minimum supported SharePoint version of the app. To fix this, go to the SharePoint tab on the app for SharePoint project’s properties page, and change the Target
SharePoint Version property to the version of the SharePoint site or lower.
Would you please let me know how can I resolve this deployment error ?
Note : I am using MVC web Application template for web project
Thank you in advance.
Kind Regards,
Dipti ChhatrapatiNot sure, but this is straight.
Project type - apps for sharepoint --> Enter URL --> select type as provider hosted app --> MVC --> Authentication Option.
Now when publishing the project - SP App to SharePoint/Office Store and web portion to any web server ( i generally do it in Azure).
Thanks, Ashish | Please mark a post helpful/answer if it is helpful or answer your query. -
SharePoint Online - Provider hosted App - Deployed in on-premise environment
Hi
We are evaluating SharePoint online and wanted to know if the following is possible? If yes, can anyone share his/her experience and issues faced?
We want to deploy a provider-hosted app to a on-premise environment. This app will need to connect to SharePoint online. What are the requirements from hosting perspective for the on-premise server? Does the server require anything specific so that it is
able to connect to SPOnline? Should it be outside the corporate firewall?
What is the difference between SharePoint online standard and dedicated plans, in the context of Provider hosted app. Are there limitations with respect to what can & cannot be done in a Provider hosted app in these environments?
How do I know if am using a SharePoint online standard or a dedicated plan? Where to look for?
I have seen few articles where the provider hosted app is deployed to windows azure and is connecting to SharePoint online. However this is not the case with us (i.e. we do not have windows azure for now)
Regards,
DevenBelow links answer most of your questions:
App- code
http://msdn.microsoft.com/en-us/library/office/fp142381(v=office.15).aspx
How to create high trust apps- http://msdn.microsoft.com/en-us/library/office/fp179901(v=office.15).aspx
How to deploy- http://msdn.microsoft.com/en-us/library/office/jj860570(v=office.15).aspx
Go to billing and subscriptions and you will see what plan you have. Dedicated plans names and options are in this link- http://technet.microsoft.com/en-us/library/dn151715.aspx
Regards
Libin
Whenever you see a reply and if you think is helpful, click "Vote As Helpful"! And whenever you see a reply being an answer to the question of the thread, click "Mark As Answer Feel free to unmark answer if does not resolves your problem. -
Provider hosted app - Site Provisioning activities
Hi ,
I am creating a Provider hosted app which does site provisioning activities like create site , create site columns, content types etc. I have almost 50 or more fields to be added. I am using the Provider hosted app - Process Event, and used SPRemoteEventType
- App Installed.
When the app is installed the above functionalities are done, as I need to code to do these activities synchronously.
I am facing an issue in App Installed event that,during the code execution (consider the field creation method), since it takes some time to add all the fields, after some time limit, the runtime comes to the start point of code execution , which is
creation of token helper, and the methods already executed is also called again.
I have executed the code in Release mode, the logs show the above behavior.
I am not sure how I am getting this weird behavoir.
Please advise.msdn (Handling events in apps for SharePoint):
Your implementation of the App Installed event must complete and return an SPRemoteEventResult object
within 30 seconds or the SharePoint installation infrastructure will think it has failed. The infrastructure will rerun the event, and repeat your code from the beginning, up to four times. After four timeouts,
SharePoint will roll back the entire app installation. We recommend the following practices:
If there is any code in your handler that should not be repeated after a timeout, put it in a conditional block that tests to see if it has already run. You must test the actual installed component. Simply setting
a variable to true when a block of code completes does not work as a test because all variables are reinitialized when the event times out and restarts.
Move installation code that takes more than 30 seconds into the app itself. You can add it to "first run" logic that executes the first time the app is launched. Alternatively, the app can prompt the
user to run the installation code.
If the preceding bullet item is not feasible for your app, another option is to have your event handler start a remote asynchronous process and then immediately return a SPRemoteEventResultobject.
A weakness of this strategy is that if the remote process fails, it has no way to tell SharePoint to roll back the app installation.
[custom.development] -
Security certificate issue for Provider Hosted App (SP Online)
Hi all,
I am having a hard time with SP Online debugging a basic provider hosted app.
Steps I have taken to create the app:
created a new provider hosted app in Visual Studio 2013 and setting my SP Online debugging site (wich works perfectly for SP hosted apps).
Chose Azure ACS option, although I do not have an Azure account
When I deploy the app I get to the page on my debugging site where I must choose "Trust It", but when I do I get the message that the Connection is Unsecure/unsafe:
How can I fix this? Do I need to create an Azure account for debugging purposes already? Or is there another way to solve the problem?Hi,
I understand that you get Security certificate issue for Provider Hosted App (SP Online).
Per my knowledge, you need to create an Azure account for debugging purposes.
To create a SharePoint 2013 app for Office 365 and publish it to an Azure web site, you can refer to:
http://blogs.msdn.com/b/kaevans/archive/2014/02/24/creating-a-sharepoint-2013-app-with-azure-web-sites.aspx
Best Regards,
Linda Li
Linda Li
TechNet Community Support -
Retrieve data from a list in SharePoint 2013 provider hosted App using CSOM
I have developed a provider hosted app in SharePoint 2013. As you already know, Visual Studio creates web application and SharePoint app. The web application gets hosted inside IIS and the SharePoint App in SharePoint site collection. I'm trying to get
data from a list hosted in SharePoint using CSOM. But I get ran insecure content error.
here is my code in Default.aspx
<script type="text/javascript" src="../Scripts/jquery-1.8.2.js"></script>
<script type="text/javascript" src="../Scripts/MicrosoftAjax.js"></script>
<script type="text/javascript" src="../Scripts/SP.Core.js"></script>
<script type="text/javascript" src="../Scripts/INIT.JS"></script>
<script type="text/javascript" src="../Scripts/SP.Runtime.js"></script>
<script type="text/javascript" src="../Scripts/SP.js"></script>
<script type="text/javascript" src="../Scripts/SP.RequestExecutor.js"></script>
<script type="text/javascript" src="../Scripts/App.js"></script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<input id="Button1" type="button" value="Get title via CSOM" onclick="execCSOMTitleRequest()" /> <br />
<input id="Button2" type="button" value="Get Lists via CSOM" onclick="execCSOMListRequest()" />
</div>
<p ID="lblResultTitle"></p><br />
<p ID="lblResultLists"></p>
</form>
</body>
</html>
and App.js is:
var hostwebUrl;
var appwebUrl;
// Load the required SharePoint libraries
$(document).ready(function () {
//Get the URI decoded URLs.
hostwebUrl =
decodeURIComponent(
getQueryStringParameter("SPHostUrl")
appwebUrl =
decodeURIComponent(
getQueryStringParameter("SPAppWebUrl")
// resources are in URLs in the form:
// web_url/_layouts/15/resource
var scriptbase = hostwebUrl + "/_layouts/15/";
// Load the js files and continue to the successHandler
//$.getScript(scriptbase + "/MicrosoftAjax.js",
// function () {
// $.getScript(scriptbase + "SP.Core.js",
// function () {
// $.getScript(scriptbase + "INIT.JS",
// function () {
// $.getScript(scriptbase + "SP.Runtime.js",
// function () {
// $.getScript(scriptbase + "SP.js",
// function () { $.getScript(scriptbase + "SP.RequestExecutor.js", execCrossDomainRequest); }
function execCrossDomainRequest() {
alert("scripts loaded");
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];
function execCSOMTitleRequest() {
var context;
var factory;
var appContextSite;
var collList;
//Get the client context of the AppWebUrl
context = new SP.ClientContext(appwebUrl);
//Get the ProxyWebRequestExecutorFactory
factory = new SP.ProxyWebRequestExecutorFactory(appwebUrl);
//Assign the factory to the client context.
context.set_webRequestExecutorFactory(factory);
//Get the app context of the Host Web using the client context of the Application.
appContextSite = new SP.AppContextSite(context, hostwebUrl);
//Get the Web
this.web = context.get_web();
//Load Web.
context.load(this.web);
context.executeQueryAsync(
Function.createDelegate(this, successTitleHandlerCSOM),
Function.createDelegate(this, errorTitleHandlerCSOM)
//success Title
function successTitleHandlerCSOM(data) {
$('#lblResultTitle').html("<b>Via CSOM the title is:</b> " + this.web.get_title());
//Error Title
function errorTitleHandlerCSOM(data, errorCode, errorMessage) {
$('#lblResultLists').html("Could not complete CSOM call: " + errorMessage);
function execCSOMListRequest() {
var context;
var factory;
var appContextSite;
var collList;
//Get the client context of the AppWebUrl
context = new SP.ClientContext(appwebUrl);
//Get the ProxyWebRequestExecutorFactory
factory = new SP.ProxyWebRequestExecutorFactory(appwebUrl);
//Assign the factory to the client context.
context.set_webRequestExecutorFactory(factory);
//Get the app context of the Host Web using the client context of the Application.
appContextSite = new SP.AppContextSite(context, hostwebUrl);
//Get the Web
this.web = context.get_web();
// Get the Web lists.
collList = this.web.get_lists();
//Load Lists.
context.load(collList);
context.executeQueryAsync(
Function.createDelegate(this, successListHandlerCSOM),
Function.createDelegate(this, errorListHandlerCSOM)
//Success Lists
function successListHandlerCSOM() {
var listEnumerator = collList.getEnumerator();
$('#lblResultLists').html("<b>Via CSOM the lists are:</b><br/>");
while (listEnumerator.moveNext()) {
var oList = listEnumerator.get_current();
$('#lblResultLists').append(oList.get_title() + " (" + oList.get_itemCount() + ")<br/>");
//Error Lists
function errorListHandlerCSOM(data, errorCode, errorMessage) {
$('#lblResultLists').html("Could not complete CSOM Call: " + errorMessage);
Any solution is appreciated.Hi,
To retrieve data from list in your provider-hosted app using SharePoint Client Object Model(CSOM), you can follow the links below for a quick start:
http://msdn.microsoft.com/en-us/library/office/fp142381(v=office.15).aspx
http://blogs.msdn.com/b/steve_fox/archive/2013/02/22/building-your-first-provider-hosted-app-for-sharepoint-part-2.aspx
Best regards
Patrick Liang
TechNet Community Support -
SharePoint Provider Hosted App that can update existing SharePoint Task List
Note: I am unable to take advantage of the Microsoft.SharePoint library directly. Adding a reference results in a 32bit/64bit library mismatch error.
I have to find a solution that uses only the Microsoft.SharePoint.Client extension.
I am looking for example code where provider-hosted SharePoint App loads a SharePoint Task List View that allows users to interact with the tasks.
So far I have only been able to programmatically create and then load the SharePoint tasks list, create and populate a DataTable object and set the datasource of a GridView object to that DataTable.
I am unable to trigger my method linked to my checkbox within the gridview.
Ideally I would like to just customize a Task View that already has this functionality.
Here is my default.aspx.cs code-behind file:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using SP = Microsoft.SharePoint.Client;
namespace SPAppBasicWeb
public partial class Default : System.Web.UI.Page
protected void Page_PreInit(object sender, EventArgs e)
Uri redirectUrl;
switch (SharePointContextProvider.CheckRedirectionStatus(Context, out redirectUrl))
case RedirectionStatus.Ok:
return;
case RedirectionStatus.ShouldRedirect:
Response.Redirect(redirectUrl.AbsoluteUri, endResponse: true);
break;
case RedirectionStatus.CanNotRedirect:
Response.Write("An error occurred while processing your request.");
Response.End();
break;
protected void Page_Load(object sender, EventArgs e)
// The following code gets the client context and Title property by using TokenHelper.
// To access other properties, the app may need to request permissions on the host web.
var spContext = SharePointContextProvider.Current.GetSharePointContext(Context);
using (var clientContext = spContext.CreateUserClientContextForSPHost())
//clientContext.Load(clientContext.Web, web => web.Title);
//clientContext.ExecuteQuery();
//Response.Write(clientContext.Web.Title);
SP.ClientContext cc = new SP.ClientContext("http://server/sites/devapps");
SP.Web web = cc.Web;
SP.List list = web.Lists.GetByTitle("General Tasks");
SP.CamlQuery caml = new SP.CamlQuery();
Microsoft.SharePoint.Client.ListItemCollection items = list.GetItems(caml);
cc.Load<Microsoft.SharePoint.Client.List>(list);
cc.Load<Microsoft.SharePoint.Client.ListItemCollection>(items);
//try
//const int ColWidth = 40;
cc.ExecuteQuery();
DataTable dt = new DataTable();
dt.Columns.Add("Task Name", typeof(string));
dt.Columns.Add("ID", typeof(int));
foreach (Microsoft.SharePoint.Client.ListItem liTask in items)
DataRow dr = dt.NewRow();
dr["Task Name"] = liTask["Title"];
dr["ID"] = liTask["ID"];
//dr["chkTask"] = liTask["Checkmark"];
dt.Rows.Add(dr);
GridView1.DataSource = dt;
GridView1.DataBind();
protected void chkTask_CheckedChanged(object sender, EventArgs e)
//add code here to update Task Item by ID
Response.Write("checkbox event triggered");
Here is my simple default.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="SPAppBasicWeb.Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="chkTask" runat="server" OnCheckedChanged="chkTask_CheckedChanged" AutoPostBack="true" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</form>
</body>
</html>
http://www.net4geeks.com Who said I was a geek?Hi,
Please try to modify your code as below:
using (var clientContext = spContext.CreateUserClientContextForSPHost())
SP.Web web = clientContext.Web;
SP.List list = web.Lists.GetByTitle("General Tasks");
SP.CamlQuery caml = new SP.CamlQuery();
Microsoft.SharePoint.Client.ListItemCollection items = list.GetItems(caml);
clientContext.Load(items);
clientContext.ExecuteQuery();
If the code still not works, I suggest you debug the code or following the blog below to create a Provider-Hosted App for SharePoint and read list items from SharePoint list.
http://blogs.msdn.com/b/steve_fox/archive/2013/02/22/building-your-first-provider-hosted-app-for-sharepoint-part-2.aspx
Best Regards
Dennis Guo
TechNet Community Support -
Hello all,
Could you possibly help me with provider-hosted app development/deployment process.
We developed SharePoint provider-hosted app that works just fine in development environment. Now we need to automate it's installation in test environment via powershell.
In AppManifest.xml that we are deploying we have key instead of explicit URL:
<App xmlns="http://schemas.microsoft.com/sharepoint/2012/app/manifest" Name="ShowAllRoomsApp" ProductID="{922a18aa-5592-b59a-4da9-4791baef02e7}" Version="1.0.0.0"
SharePointMinVersion="15.0.0.0">
<Properties>
<Title>SomeTitle</Title>
<StartPage>~remoteAppUrl/Pages/Default.aspx?{StandardTokens}</StartPage>
If we use as
https://technet.microsoft.com/en-us/library/jj655398.aspx recommends, we cannot specify Redirect Url as we can do this on
/_layouts/appinv.aspx
So now it seems like the only way to deploy this kind of solution is using appinv.aspx page.Or must we apply this URL in AppManifest on developing stage in Visual Studio?
What did I miss?
P. S. Even if I use /_layouts/appinv.aspx after powershell commandlets, I get error.hi,
to deploy provider hosted app you need 2 things
1. Client ID
2. Redirect URL.
What you can do you can generate app from visual studio using clientID and URL from developer enviornment.
Now a app file is just a simple compressed zip file if you rename it as .zip and extract you will find AppManifest
inside it. So to create an app for Testing enviornment what you have to to Get the CLient ID (from AppRegNew.aspx) in testing enviornment. Unzip .App file change the AppManifest with testing client ID and URL than again zip file and rename as .app.
Now if you upload this file it will work.
To automate this scenerio i have created a simple windows Application in which i Pass the Client ID and StartURl and an App File it unzips the app file make changes to app and again zip it.
public static class AppPackageHelper
public const string StartUrlExpression = "{0}?{1}";
public const string StandardToken = "{StandardTokens}";
public static string Publish(string appPath, string ClientId,string StartUrl)
string tempDir = string.Empty;
string outPutFile = string.Empty;
try
string parentDir = System.IO.Path.GetDirectoryName(appPath);
outPutFile = System.IO.Path.Combine(parentDir, ClientId + "-Winshuttle.app");
tempDir = System.IO.Path.Combine(parentDir, ClientId.ToString());
Directory.CreateDirectory(tempDir);
int lastInd = appPath.LastIndexOf('.');
string tempPath = string.Empty;
string targetFilePath = string.Empty;
string cabPath = System.IO.Path.Combine(tempDir, System.IO.Path.GetFileNameWithoutExtension(appPath) + ".cab");
FileInfo fInfo = new FileInfo(appPath) { IsReadOnly = false };
File.Copy(appPath, cabPath);
XDocument doc = null;
string appManifest = string.Empty;
using (ZipArchive zipArch = ZipFile.Open(cabPath, ZipArchiveMode.Update))
appManifest = string.Format(@"{0}\AppManifest.xml", Directory.GetParent(cabPath).FullName);
ZipArchiveEntry manifestEntry = zipArch.Entries.LastOrDefault(e => e.Name.ToLower() == "appmanifest.xml");
manifestEntry.ExtractToFile(appManifest);
doc = XDocument.Load(appManifest);
XNamespace ns = doc.Root.GetDefaultNamespace();
string defaultUrl = string.Format(StartUrlExpression, StartUrl.TrimEnd('/'), StandardToken);
doc.Descendants(XName.Get("StartPage", ns.NamespaceName)).First().Value = defaultUrl;
doc.Descendants(XName.Get("RemoteWebApplication", ns.NamespaceName)).First().Attribute(XName.Get("ClientId")).Value = setupInfo.ClientId.ToString();
doc.Save(appManifest);
if (manifestEntry != null)
manifestEntry.Delete();
zipArch.CreateEntryFromFile(appManifest, "AppManifest.xml");
int totEnt = zipArch.Entries.Count;
for (int e = 0; e < totEnt; e++)
if (zipArch.Entries[e].Open().Length == 0)
//if (zipArch.Entries.Count > totEnt && e >= totEnt) break;
//zipArch.CreateEntry(zipArch.Entries[e].FullName);
File.Delete(appManifest);
if (File.Exists(outPutFile))
File.Delete(outPutFile);
File.Move(cabPath, outPutFile);
return outPutFile;
catch
throw;
finally
if (System.IO.Directory.Exists(tempDir))
System.IO.Directory.Delete(tempDir, true);
return outPutFile;
using System.IO.Compression.FileSystem.dll.
Also if you want to do it using powershell You need to do the same thing unzip-> changes values-> zip
So basic thing is You need to ahve only valid AppManifest file which contains 2 valid values Client Id and StartUrl
if you changes it inside appmanifest manuall than it will also work. Using above code you can create a console Application to do it. You can use powershell it just that i dont know how to zip unzip in powershell but i am pretty sure you can easily find it
on searching.
Whenever you see a reply and if you think is helpful,Vote As Helpful! And whenever you see a reply being an answer to the question of the thread, click Mark As Answer -
Hi,
Any help appreciated!!
I'm getting this error: "The remote server returned an error: (401) unauthorised when I debug a provider-hosted app. I get the error on this line:
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
See code below
I created a high trust development environment following the instructions provided here:
http://msdn.microsoft.com/en-us/library/office/fp179901(v=office.15).aspx and
http://msdn.microsoft.com/library/office/fp179923
I created a provider-hosted app with the intent to:
create a SharePoint list in the appweb
Use self-signed certificate, tokenhepler.cs and sharepointcontext.cs to retrieve current user context and access on SharePoint. (No changes were made to tokenhelper.cs and sharepointcontext.cs)
retrieve list items from the SharePoint list in a button click event handler on a default.aspx of the remote web
What happens:
The app is deployed successfully to the Dev site
The SharePoint feature is deployed and activated
The default.aspx page of the remote web loads
The error (see image) is returned on clicking of the button
My environment is an on-premise SharePoint 2013 with AD and my dev box is standalone windows 8.1 running Visual Studio Professional 2013 Update 3.
The code block below is a copy of the default.aspx code-behind
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.SharePoint.Client;
using Microsoft.IdentityModel.S2S.Tokens;
using System.Net;
using System.IO;
using System.Xml;
using System.Data;
using System.Xml.Linq;
using System.Xml.XPath;
namespace Idea.GeneratorWeb
public partial class Default : System.Web.UI.Page
SharePointContextToken contextToken;
string accessToken;
Uri sharepointUrl;
protected void Page_PreInit(object sender, EventArgs e)
Uri redirectUrl;
switch (SharePointContextProvider.CheckRedirectionStatus(Context, out redirectUrl))
case RedirectionStatus.Ok:
return;
case RedirectionStatus.ShouldRedirect:
Response.Redirect(redirectUrl.AbsoluteUri, endResponse: true);
break;
case RedirectionStatus.CanNotRedirect:
Response.Write("An error occurred while processing your request.");
Response.End();
break;
protected void Page_Load(object sender, EventArgs e)
//// The following code gets the client context and Title property by using TokenHelper.
//// To access other properties, the app may need to request permissions on the host web.
var spContext = SharePointContextProvider.Current.GetSharePointContext(Context);
//var spContext = new ClientContext("MySPDevInstance");
//spContext.Credentials = new NetworkCredential("username", "password");
//using (var clientContext = spContext.CreateUserClientContextForSPHost())
// clientContext.Load(clientContext.Web, web => web.Title);
// clientContext.ExecuteQuery();
// Response.Write(clientContext.Web.Title);
string contextTokenString = TokenHelper.GetContextTokenFromRequest(Request);
if (contextTokenString != null)
// Get context token
contextToken = TokenHelper.ReadAndValidateContextToken(contextTokenString, Request.Url.Authority);
// Get access token
sharepointUrl = new Uri(Request.QueryString["SPAppWebUrl"]);
accessToken = TokenHelper.GetAccessToken(contextToken, sharepointUrl.Authority).AccessToken;
// Pass the access token to the button event handler.
Button1.CommandArgument = accessToken;
protected void Button1_Click(object sender, EventArgs e)
// Retrieve the access token that the Page_Load method stored
// in the button's command argument.
string accessToken = ((Button)sender).CommandArgument;
if (IsPostBack)
sharepointUrl = new Uri(Request.QueryString["SPAppWebUrl"]);
// REST/OData URL section
string oDataUrl = "/_api/Web/lists/getbytitle('Diagrams In Idea Generator')/items?$select=Title,Diagram,SharingStatus";
// HTTP Request and Response construction section
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(sharepointUrl.ToString() + oDataUrl);
request.Method = "GET";
request.Accept = "application/atom+xml";
request.ContentType = "application/atom+xml;type=entry";
request.Headers.Add("Authorization", "Bearer " + accessToken);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
// Response markup parsing section
XDocument oDataXML = XDocument.Load(response.GetResponseStream(), LoadOptions.None);
XNamespace atom = "http://www.w3.org/2005/Atom";
XNamespace d = "http://schemas.microsoft.com/ado/2007/08/dataservices";
XNamespace m = "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata";
List<XElement> entries = oDataXML.Descendants(atom + "entry")
.Elements(atom + "content")
.Elements(m + "properties")
.ToList();
var entryFieldValues = from entry in entries
select new
Character = entry.Element(d + "Title").Value,
Actor = entry.Element(d + "Diagram").Value,
CastingStatus = entry.Element(d + "SharingStatus").Value
GridView1.DataSource = entryFieldValues;
GridView1.DataBind();
Any ideas what I might be doing wrongHi ,
Use the below code
Public string GetAccessToken(){
string sharePointSiteUrlHost = Page.Request["SPHostUrl"].Tostring();
string AccessToken = tokenHelper.GetS2SAccessTokenWithWindowsIdentity(sharePointSiteUrlHost, Request.LogonUserIdentity);
return accessToken;
Than initialize the ClientCOntext with the below Method
private static ClientContext GetClientContextWithAccessTokenString(string targetUrl, object accessToken)
ClientContext clientContext = new ClientContext(targetUrl);
clientContext.AuthenticationMode = ClientAuthenticationMode.Anonymous;
clientContext.FormDigestHandlingEnabled = false;
clientContext.ExecutingWebRequest +=
delegate(object oSender, WebRequestEventArgs webRequestEventArgs)
webRequestEventArgs.WebRequestExecutor.WebRequest.UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)";
webRequestEventArgs.WebRequestExecutor.RequestHeaders["Authorization"] =
"Bearer " + accessToken;
return clientContext;
use this clientCOntext and it will work.
Do not use
SharePointContextProvider
Whenever you see a reply and if you think is helpful,Vote As Helpful! And whenever you see a reply being an answer to the question of the thread, click Mark As Answer -
Error occurred in deployment step 'Install app for SharePoint, ULS log as below:
0x0BA8 SharePoint Foundation App Deployment acjjg Medium The current user has System.Threading.Thread.CurrentPrincipal.Identity.Name
= 0#.w|perf\abraham.lincoln, System.Security.Principal.WindowsIdentity.GetCurrent().Name = NT AUTHORITY\IUSR, System.Web.HttpContext.Current.User.Identity.Name = 0#.w|perf\abraham.lincoln. dcf1d59c-94c5-5071-47bf-07cd3f2ead95
12/14/2014 23:54:27.39 w3wp.exe (0x2170) 0x0BA8 SharePoint Foundation
App Deployment ag8d6 Medium SPApp: CreateAppUsingPackageMetadata: isCabStream is false. Treating the stream as a ZIP. dcf1d59c-94c5-5071-47bf-07cd3f2ead95
12/14/2014 23:54:27.39 w3wp.exe (0x2170) 0x0BA8 SharePoint Foundation
App Deployment ahkn9 High Deleting App with fingerprint TJQrYuD5N+kEe38LZtl6wSs3Ak3yYvWcmwuNLTqtpdFzb4qSMopN3SWCRdWvntrKoM7qIS2S2llpA5omi8iHqQ==
on site 264dc389-d394-4985-a43c-ad91a383c0df dcf1d59c-94c5-5071-47bf-07cd3f2ead95
12/14/2014 23:54:27.39 w3wp.exe (0x2170) 0x0BA8 SharePoint Foundation
App Deployment ahkob High The App with fingerprint TJQrYuD5N+kEe38LZtl6wSs3Ak3yYvWcmwuNLTqtpdFzb4qSMopN3SWCRdWvntrKoM7qIS2S2llpA5omi8iHqQ==
on site 264dc389-d394-4985-a43c-ad91a383c0df was to be deleted, but it did not exist dcf1d59c-94c5-5071-47bf-07cd3f2ead95
12/14/2014 23:54:27.41 w3wp.exe (0x2170) 0x0BA8 SharePoint Foundation
App Deployment abnqa Medium App Packaging: CreatePackage: There are 10 parts in the package. There are 1 package-part relationships
in the package. dcf1d59c-94c5-5071-47bf-07cd3f2ead95
12/14/2014 23:54:27.41 w3wp.exe (0x2170) 0x0BA8 SharePoint Foundation
App Deployment afyz6 Medium SPAppResources: ParseResources: No default resource file was found. dcf1d59c-94c5-5071-47bf-07cd3f2ead95
12/14/2014 23:54:27.41 w3wp.exe (0x2170) 0x0BA8 SharePoint Foundation
App Deployment afyzx Medium SPAppResources: ParseResources: no resource file relationships were found. dcf1d59c-94c5-5071-47bf-07cd3f2ead95
12/14/2014 23:54:27.41 w3wp.exe (0x2170) 0x0BA8 SharePoint Foundation
App Deployment aebgs Medium SPPackageUtility: ExtractPart: Creating directory 'C:\Users\abraham.lincoln.PERF\AppData\Local\Temp\71345ca6-3565-43d8-9017-2d3336965d8f\extract' dcf1d59c-94c5-5071-47bf-07cd3f2ead95
12/14/2014 23:54:27.41 w3wp.exe (0x2170) 0x0BA8 SharePoint Foundation
App Deployment aebgt Medium SPPackageUtility: ExtractPart: Creating file 'C:\Users\abraham.lincoln.PERF\AppData\Local\Temp\71345ca6-3565-43d8-9017-2d3336965d8f\extract\AppManifest.xml' dcf1d59c-94c5-5071-47bf-07cd3f2ead95
12/14/2014 23:54:27.41 w3wp.exe (0x2170) 0x0BA8 SharePoint Foundation
App Deployment ajddw Medium SPPackageUtility: ExtractPart: Part stream length is '1072'. dcf1d59c-94c5-5071-47bf-07cd3f2ead95
12/14/2014 23:54:27.41 w3wp.exe (0x2170) 0x0BA8 SharePoint Foundation
App Deployment ajddz Medium SPPackageUtility: ExtractPart: Length is '1072', not locking before copying the stream. dcf1d59c-94c5-5071-47bf-07cd3f2ead95
12/14/2014 23:54:27.41 w3wp.exe (0x2170) 0x0BA8 SharePoint Foundation
App Deployment aebgt Medium SPPackageUtility: ExtractPart: Creating file 'C:\Users\abraham.lincoln.PERF\AppData\Local\Temp\71345ca6-3565-43d8-9017-2d3336965d8f\extract\AppIcon.png' dcf1d59c-94c5-5071-47bf-07cd3f2ead95
12/14/2014 23:54:27.41 w3wp.exe (0x2170) 0x0BA8 SharePoint Foundation
App Deployment ajddw Medium SPPackageUtility: ExtractPart: Part stream length is '3540'. dcf1d59c-94c5-5071-47bf-07cd3f2ead95
12/14/2014 23:54:27.41 w3wp.exe (0x2170) 0x0BA8 SharePoint Foundation
App Deployment ajddz Medium SPPackageUtility: ExtractPart: Length is '3540', not locking before copying the stream. dcf1d59c-94c5-5071-47bf-07cd3f2ead95
12/14/2014 23:54:27.41 w3wp.exe (0x2170) 0x0BA8 SharePoint Foundation
App Deployment aidi7 Medium SPIconAppPartValidator: IsSupportedFormat: image raw format is 'b96b3caf-0728-11d3-9d7b-0000f81ef32e'. dcf1d59c-94c5-5071-47bf-07cd3f2ead95
12/14/2014 23:54:27.42 w3wp.exe (0x2170) 0x0BA8 SharePoint Foundation
App Deployment afyz6 Medium SPAppResources: ParseResources: No default resource file was found. dcf1d59c-94c5-5071-47bf-07cd3f2ead95
12/14/2014 23:54:27.42 w3wp.exe (0x2170) 0x0BA8 SharePoint Foundation
App Deployment afyzx Medium SPAppResources: ParseResources: no resource file relationships were found. dcf1d59c-94c5-5071-47bf-07cd3f2ead95
12/14/2014 23:54:27.42 w3wp.exe (0x2170) 0x0BA8 SharePoint Foundation
App Deployment aebgt Medium SPPackageUtility: ExtractPart: Creating file 'C:\Users\abraham.lincoln.PERF\AppData\Local\Temp\71345ca6-3565-43d8-9017-2d3336965d8f\extract\featurecc1deab7-efdf-4cc2-80ae-60e073577d64.xml' dcf1d59c-94c5-5071-47bf-07cd3f2ead95
12/14/2014 23:54:27.42 w3wp.exe (0x2170) 0x0BA8 SharePoint Foundation
App Deployment ajddw Medium SPPackageUtility: ExtractPart: Part stream length is '321'. dcf1d59c-94c5-5071-47bf-07cd3f2ead95
12/14/2014 23:54:27.42 w3wp.exe (0x2170) 0x0BA8 SharePoint Foundation
App Deployment ajddz Medium SPPackageUtility: ExtractPart: Length is '321', not locking before copying the stream. dcf1d59c-94c5-5071-47bf-07cd3f2ead95
12/14/2014 23:54:27.42 w3wp.exe (0x2170) 0x0BA8 SharePoint Foundation
App Deployment aebgt Medium SPPackageUtility: ExtractPart: Creating file 'C:\Users\abraham.lincoln.PERF\AppData\Local\Temp\71345ca6-3565-43d8-9017-2d3336965d8f\extract\elements4d87f314-4b0a-4b89-8a7e-9cb73c99f25f.xml' dcf1d59c-94c5-5071-47bf-07cd3f2ead95
12/14/2014 23:54:27.42 w3wp.exe (0x2170) 0x0BA8 SharePoint Foundation
App Deployment ajddw Medium SPPackageUtility: ExtractPart: Part stream length is '849'. dcf1d59c-94c5-5071-47bf-07cd3f2ead95
12/14/2014 23:54:27.42 w3wp.exe (0x2170) 0x0BA8 SharePoint Foundation
App Deployment ajddz Medium SPPackageUtility: ExtractPart: Length is '849', not locking before copying the stream. dcf1d59c-94c5-5071-47bf-07cd3f2ead95
12/14/2014 23:54:27.42 w3wp.exe (0x2170) 0x0BA8 SharePoint Foundation
App Deployment aerhy Medium App Packaging - List of App Parts (count ='2'): Name='SPIconAppPart',Name='SPFeatureAppPart', dcf1d59c-94c5-5071-47bf-07cd3f2ead95
12/14/2014 23:54:27.42 w3wp.exe (0x2170) 0x0BA8 SharePoint Foundation
App Deployment aerhz Medium App Packaging - List of Deployment Groups (count ='3'): Name='SPIconDeploymentGroup',Name='SPTargetWebDeploymentGroup',Name='SPQuickLaunchDeploymentGroup', dcf1d59c-94c5-5071-47bf-07cd3f2ead95
12/14/2014 23:54:27.42 w3wp.exe (0x2170) 0x0BA8 SharePoint Foundation
App Deployment mq71 Medium Creating App with fingerprint TJQrYuD5N+kEe38LZtl6wSs3Ak3yYvWcmwuNLTqtpdFzb4qSMopN3SWCRdWvntrKoM7qIS2S2llpA5omi8iHqQ==
to site 264dc389-d394-4985-a43c-ad91a383c0df. dcf1d59c-94c5-5071-47bf-07cd3f2ead95
12/14/2014 23:54:27.44 w3wp.exe (0x2170) 0x0BA8 SharePoint Foundation
App Deployment afpd2 Medium Committing package with fingerprint TJQrYuD5N+kEe38LZtl6wSs3Ak3yYvWcmwuNLTqtpdFzb4qSMopN3SWCRdWvntrKoM7qIS2S2llpA5omi8iHqQ==
and data length 8010 to site 264dc389-d394-4985-a43c-ad91a383c0df. dcf1d59c-94c5-5071-47bf-07cd3f2ead95
12/14/2014 23:54:27.46 w3wp.exe (0x2170) 0x0BA8 SharePoint Foundation
App Deployment ajk9e Medium Writing 8010 bytes to database for app with fingerprint TJQrYuD5N+kEe38LZtl6wSs3Ak3yYvWcmwuNLTqtpdFzb4qSMopN3SWCRdWvntrKoM7qIS2S2llpA5omi8iHqQ== dcf1d59c-94c5-5071-47bf-07cd3f2ead95
12/14/2014 23:54:27.50 w3wp.exe (0x2170)Hi Jerry,
I agree with Nikhil, I think you have posted partial ULS log, we could not find effective errors for the issue.
For Provider Hosted app in SharePoint server on-premise,
the TokenHelper class will try to access your Azure Security Principle by default.
Did you have a valid Azure account?
If not, the issue may be caused that you don't have a valid account, to resolve this issue, you can use
a valid Azure account or not going to use Azure Platform for hosting the app as the article
below.
http://pratapreddypilaka.blogspot.jp/2012/12/sharepoint-2013-avoiding-azure-on-dev.html
Thanks,
Jason
Jason Guo
TechNet Community Support -
Report Viewer control in sharepoint 2013 provider hosted app
sharepointSite/_vti_bin/ReportServer
We are migrating sp 2010 site to SP 2013 provider hosted app. we are using Report viewer control (version 10.0.0) in .net application app server, And the reporting service is configured in sharepoint site and report is uploaded in the document
library. We are using claims based authentication
ReportViewer1.ServerReport.ReportServerUrl =
newUri("sharepointSite/_vti_bin/ReportServer");
ReportViewer1.ServerReport.ReportPath = @"sharepointSite/_vti_bin/ReportServer?sharepointSite/Reports/Report1.rdl";
and am getting an error
ReportServerException: For more information about this error navigate to the report server on the local server machine, or enable remote errors]
[ReportServerException: The user does not exist or is not unique.]
[ReportServerException: Report Server has encountered a SharePoint error. (rsSharePointError)]
Microsoft.Reporting.WebForms.ServerReportSoapProxy.OnSoapException(SoapException e) +82
Microsoft.Reporting.WebForms.Internal.Soap.ReportingServices2005.Execution.ProxyMethodInvocation.Execute(RSExecutionConnection connection, ProxyMethod`1 initialMethod,
ProxyMethod`1 retryMethod) +770
Microsoft.Reporting.WebForms.ServerReport.EnsureExecutionSession() +105
Microsoft.Reporting.WebForms.ServerReport.SetParameters(IEnumerable`1 parameters) +163
BP.SDC.eXPP.UIAppsWeb.UserControls.Baseline.ProgressDashboard.RefreshDashboardReport(Int32 userRoadMapDisciplineId, String roadmapSection)
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3804
Can you please help me to solve this issueHi,
According to your post, my understanding is that you had issues about the provider hosted app.
Per the error, the issue may be related to the permission issue.
For a better troubleshooting, we can check with the following steps.
To norrow down the issue, please create a new and clean app to test whether it has the same issue.
You can check the ULS log to see if anything unexpected occurred when you deploy the app and open the site page.
For SharePoint 2013, by default, ULS log is at
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\LOGS
You can check the ULS log by the methods here:
http://blogs.msdn.com/b/opal/archive/2009/12/22/uls-viewer-for-sharepoint-2010-troubleshooting.aspx
http://msdn.microsoft.com/en-us/library/gg193966(v=office.14).aspx
Thanks,
Jason
Forum Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
[email protected]
Jason Guo
TechNet Community Support -
Hi,
We are trying to deploy the provider hosted app in server environment . we are getting the "The remote server returned an error :(401) unauthorized" error after deploy the app in server.
stack Trace:
[webException:Te remote server returned an error:(401) UnAuthorized.]
System.Net.HeepWebRequest.GetResponse().
Followed the same MSDN steps , but sill same error. We have attached the certificate and using the same issuer ID in the app web.config.
Verified the IIS setting and still getting the same error when we call the "Clientcontext.ExecuteQuery()" method.
Same code is working fine in my Local dev environment.
If anyone have idea about this issue, please let me know.
Thank you,
MylsamyHi ,Thank you for your response. We have tried all the options and everything is same (Client ID,Issuer ID...etc) and finally figured out the issue.The below link saved my day.http://msdn.microsoft.com/en-us/library/office/dn762439(v=office.15).aspxIn "TokenHelper.cs" GetRealmFromTargetUrl method always return null andWhen we analyze the issue we found some variable name assigned for "Realm" Instead of GUID in SP server.Power shell command to get the Realm in SP server: Get-SPAuthenticationRealmWe have followed below article to generate the new GUID for realm.http://technet.microsoft.com/en-us/library/jj219756(v=office.15).aspx$c =Get-SPServiceContext -Site "http://<websiteurl>"Set-SPAuthenticationRealm -ServiceContext $c -Realm "a686d436-9f16-42db-09b7-cb578e110ccd".
Thankyou,Mylsamy -
Sharepoint online provider-hosted app AppEventReceiver callout failed.
I've created an AppEventReceiver for sharepoint online provider-hosted app, I can deploy the app if i hosted the remote web application on MS Azure, it work fine. if hosted the remote web application on local machine IIS whith public ip address, when
I deploy the app online the following error:
The remote event receiver callout failed.
Details: There was no endpoint listening at
http://115.193.xxx.xxx:6666/AppEventReceiver.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
two question:
1. does the provider-hosted app, (remote web application )must host on Azure so that the AppEventReceiver (appinstalled) then trigger?
2. what need to do when host on local machine IIS whith public ip address?try these link:
http://www.sharepointnutsandbolts.com/2013/07/deploying-sp2013-provider-hosted.html
if you are using office365 for sharepoint then you can develope list using sandbox solution .
Maybe you are looking for
-
Charging service tax on part amount in FB60
Hi I am booking one vendor invoice. Invoice amount is Rs.1060 (Rs. 660 is some printing stationary material (including VAT Rs.60) and Rs.400 is service charge. Now i have to charge this entire bill to printing stationary GL account. and Rs. 60 to VAT
-
Multiple Step Error Caused by SQL Syntax?
Hi All: I am getting a multiple step error when I do this: rs.Fields("MyField").Value = MyValue I finally tracked down the error to being caused by this syntax: SELECT a.* FROM MyTable a or SELECT a.MyField FROM MyTable a However, this syntax works j
-
Gitk not working since last update
Hi fellows, I tried to run gitk after the last update but it's not starting. I am getting the following message: $ gitk Application initialization failed: unknown color name "BACKGROUND" Error in startup script: can't invoke "image" command: applicat
-
Regarding Returnable Packaging
Hi Gurus, I have a problem that for a liquid of say Liquid PH-5 ,1 litre must be packed in a returnable packaging material bottle-BV1, The bottle can hold only 1 litre of the liquid and in sales order and Delivery level if i go for Packi
-
Ho All, Does Oracle enterprise database cover Oracle Spatial in 10G? I were told it is free by some friends. If it is not free in 10g, how about 11G Regards Jim