I have a small question which ends in a big topic.
Is it possible - and yes how - to use C# code in a SharePoint 2013 Hosted App?
I tried to have a .asmx file within my project.
Then I get this error.
#"Error 1
CorrelationId: 9c1ea930-a131-4f5b-bff5-8a1a61fe34d9
ErrorDetail: There was a problem with activating the app web definition.
ErrorType: App
ErrorTypeName: App Related
ExceptionMessage: Microsoft.SharePoint.SPException: Exception from HRESULT: 0x81070964 ---> System.Runtime.InteropServices.COMException: Exception from HRESULT: 0x81070964
And then I tried a few tutorials like...
http://chuvash.eu/2012/02/13/custom-httphandler-in-sharepoint-for-getting-dynamic-javascript-code/
http://blogs.msdn.com/b/kaevans/archive/2010/08/04/deploying-an-asp-net-httphandler-to-sharepoint-2010.aspx
http://social.technet.microsoft.com/wiki/contents/articles/24194.sharepoint-2013-create-a-custom-wcf-rest-service-hosted-in-sharepoint-and-deployed-in-a-wsp.aspx
But sometimes I didn't understand correctly or sometime I have other problems during compile everything.
I had a problem with getting assembly id/name, too. Because there was no compiled DDL File for the project.
What I want in general?
A .app file with a SP Hosted App (for SP 2013) which includes a web service for SP Client Object Model.
So I thinking about using the "default.aspx" with CodeBehind. So I could execute scripts "behind" the aspx. But then it couldn't find the assembly... Or there was something else.
Could anyone help me? If you have some ideas you could !please! provide them to me. Thank's!
SharePoint hosted Apps doesn't allow server side code to be excuted on the server, this is the whole idea of SharePoint Apps, nothing should be executed in the SharePoint Front End Servers. Unlike Farm solutions, SharePoint Hosted Apps runs on the client and can only access SharePoint resources through a predefined set of services that can be called either using REST or JSOM.
If you need a custom code, you can create a WCF service, deploy it under ISAPI and call it from your App, but this will not be doable in SharePoint online.
As for your question, you can use ASPX pages of course, but you will never put a code behind for it, as these pages are stored in a Pages Library and by design, it is stored in the content DB, so any code execution is denied.
Only aspx pages that are stored on hard disk like the _layouts pages can have a code behind.
SharePoint App runs in client context. You can create SharePoint App just using JS, HTML, CSS, JSOM. You cannot use C# for App (excluding CSOM, you can use it for creation remote event receiver for example)
If you need to implement some functionality to on-premise version of SharePoint, use traditional server-side solutions, not App.
It's important to understand the difference between SharePoint-hosted Apps and Provider-hosted Apps:
SharePoint-hosted Apps
SharePoint-hosted apps, or apps where all components are hosted on either an on-premises or Office 365 SharePoint farm. SharePoint-hosted apps are installed on a SharePoint 2013 website, called the host web. They have their resources hosted on an isolated subsite of a host web, called the app web. The App is created using HTML/JavaScript with CSOM or REST calls
Provider hosted apps
Provider-hosted apps for SharePoint include components that are deployed and hosted outside the SharePoint farm. They are installed to the host web, but their remote components are hosted on another server. The App run in a server that is external to SharePoint's. It has its own infrastructure and the Provider is responsible for keeping it running. They allow you to use Server Side code and uses the .NET CSOM.
This image will give you an overview of different Hosting solutions:
Visit the following link for more information:
https://msdn.microsoft.com/en-us/library/office/fp179887(v=office.15).aspx
The SharePoint Add-in model uses ASPX pages, which can also include ASPX controls. However any methods called are restricted to client-side scripting - i.e. JavaScript and SharePoint's JSOM (JavaScript Object Model), which is a subset of the Client Side Object Model.
Related
I want to create a common web module which act as a service to both .NET desktop application as well as web application (php, asp etc). Its main task is to get the input parameter from client page (can be webpage or desktop app), and do some calculations and provide the output to requested party (webpage/application). I have no experience implementing similar kind of environment and any help will be appreciated. I am using windows server and desktop application is developed in C#. Just wanted to create a common module platform for both environment. Creating a local copy of web hosted module for desktop application is preferred as it act as a copy of web module and only update when the user wants it.
The solution to your question is actually to create a Web Service here's how you can create a Web Service for visual studio
Create a asmx web service in C# using visual studio 2013
Your web service will have a method that accepts a DataSet to fetch the input of the user from the WebPage/Application(clientside) and will also have a method where it will pass the input it fetched (most appropriate is a DataSet) to the WebPage/Application you want.
P.S.
You need to Add Service Reference to the Project in the ClientSide WebPage/Application
I'm trying to understand if there is a way to make a web application run on the local computer(browser) without IIS.
My main objective is to transform my web application (that is on the internet) to a software that runs on the local computer without using the internet and without IIS.
My idea is to distributed my webapp between my colleagues and not forcing them to work online and not needing an internet connection.
I have a MVC web app with 3 pages and a couple of methods on the server side.
The idea of the application is to get proprieties from a form that I implemented on one of the pages of my web application and transform the proprieties on the client side to JSON and send it to the server, the server will generate XML file according to the JSON object and let the client download the XML file that were generated.
The flow of it:
1.The Client fill the form in my site.
2.The form become JSON object on the client side.
3.The JSON object that stored the properties of the form(filled by the client) is send to the server.
4.The server get the JSON object and generated XML document from it.
5.The client download the generated XML file.
Very simple web application.
I know that I can run HTML page by clicking it and the page will display on the browser but I need the server side to be working too to carry out actions.
So my question is : How can I make my web application run without internet ?
With the constrains:
No IIS required.
Working with .NET 4.0. (OWIN 2.0 - Not good)
No internet require.
No installation required to the computer ill pass this web app.
The server side code wont be expose when I send this application to my friends.
I read a couple of articles about OWIN, SingalR, Cassini and WCF but its all very vague...
If someone could provide me with a guide lines it will be very helpful.
Thanks a lot.
You can definitely self host a .NET web application using OWIN. Unfortunately documentation and information about it is vague and confusing at best. The fact that you're using MVC makes it somewhat easier as you may be able to directly use the self-host packages from Nuget for self hosting Web API. There may be similar packages for MVC.
I don't have recent experience but a Nuget search for "MVC Self Host" should yield some results.
Below is a link with an example. But the term you are looking for is definitely "self host". It can be done via a console window or (more complex) a windows service. It will likely use some form of OWIN but you can probably find some startup code to copy and paste into your project, usually in the form of a Startup.cs file.
http://www.c-sharpcorner.com/UploadFile/4b0136/working-with-owin-hosting-and-self-hosting-in-Asp-Net/
Need an advice on design approach. I spent couple of hours googling and still cannot come to a conclusion. Task at hand:
design intranet app that will have access control. Users should be given rights to access it.
C# is a preferred design language
app can be a simple form with some text fields and some fields as dropdown boxes from a DB
app will send SOAP request upon form completion
there should be a couple more forms like db search, preferably with sorting ability for columns
There is a Sharepoint I can get access to. Can it easily solve the access rights management or or should create a separate app on the same IIS or perhaps I shold request a separate IIS created and deal with access rights via DOTNET solutions? What is the quickest way to design this in your view?
Our SharePoint is 2010, and professional edition of VS2013 available for development.
Thank you
About SharePoint:
There is a permission management in SharePoint. You can set user permissions up to individual items, files and pages. You can read about it here: User permissions and permission levels in SharePoint 2013 and here: Fine-grained permission reference for SharePoint Server 2013. You can use differend authentication providers (AD, FBA, Oauth etc): Authentication, authorization, and security in SharePoint 2013.
You can create customization declaratively (no code), ะก# or javascript. There is built in object model (client and server) and web services (REST for 2013 or SOAP for 2010). More about SharePoint for developers
You can use built in form web parts or create custom with server code (C#) or with just HTML and javascript. All you can do with asp.net - you can do in SharePoint with custom web parts. But you can do most of things just with HTML and javascript.
You can request web services from server code (C#) or from javascript - just like in asp.net apps.
You can do db search with javascript or server code, using your prefer datagrid controls.
I think most easy way is using SharePoint 2013 Foundation (it's free if you have Windows Server license). And using javascript and HTML - in this way you don't need to know anything about deploying solutions in SharePoint etc. But you can do it via custom web parts - in this way you may do it like common asp.net development. But it's not a best way.
I was trying to access an API which contains SharePoint Server Object Model codes from a project inside WCF server. My intention is to download a document which is on SharePoint server.
My codes are inside WCF server. SharePoint server is another server.
Whenever I try to access the server using
SPSite.Exists(new Uri(spServerURL))
It does not know the server. So when I change the WCF application pool to run under the Farm admin account, it works well.
Is it OK to do like that or it will be a security breach?
How should I try to access the document ?
I think it will be better if you'll deploy your service to existing SharePoint web applications. So your service will work under SharePoint app pool account, so, you will not have problems with permissions of your service for SharePoint. Also it will be available for your SharePoint solutions from mapped path like this http:////_vti_bin/. This is useful, when you need to acces it from web contecxt you can use just relative path /_vti_bin/.
Check this link for more information about service development for SharePoint 2010.
I would like to upload some files on a server Share Point.
My questions are:
1) I started developing my project as a Windows Service but I read several parts of this WebService. It's mandatory that it's be a WebService?
2) I added the references to. Dll take it from my SharePoint Server (as seen in most discussions) but a little read more shares can not be tested if not solely on where you installed SharePoint Server. Right or there are alternative methods to do this? And also, when we deliver the service, can I install the latter on a machine where SharePoint is not installed (it seems a trivial question, but it seems strange not being able to test
but you install it).
You can only reference SharePoint 2007 assemblies from code that is running on the machine where SharePoint is installed (if you were using SharePoint 2010, you could take advantage of the Client Object Model).
Only the part of your solution that is directly interacting with SharePoint has to be created as a web service. You should create a web service with basic methods like UploadFileToLibrary, deploy it to SharePoint machine and then call these methods from the client (it can be an ASP.NET page or desktop application).
As Kit Menke pointed out in a comment below, it is possible that built-in SharePoint web services will be sufficient for you needs and you won't have to create a custom one:
Upload a file to SharePoint through the built-in web services
Copy.CopyIntoItems method