SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm working on a SharePoint-Hosted application and wondering how I can add C# code to the .aspx files. When creating Auto-Hosted and Provider-Hosted apps, they displayed a C# script for every page.

Is this not possible?

Thanks for your help!

share|improve this question
I personally don't like client side object model. Javascript and html feels like I am back to 90s can microsoft able to sovle this ?(using C# and still be able to deploy to cloud) – user34163 Oct 9 '14 at 19:29
up vote 2 down vote accepted

No this is the major limitation of SharePoint hosted apps.

To be able to run server side code you need to develop auto hosted or provider hosted apps.

See MSDN for complete comparison between the hosting options

share|improve this answer
I thought that might be the case. I initially tried auto-hosted and provider-hosted apps, but wasn't able to use Microsoft.SharePoint.WebControls to use the SPWeb and SPUser class functions. Can you use WebControls on provider/auto hosted apps? – Graham May 16 '13 at 12:59
In the App model, you are no longer able to use the server-side object model. You are now using the client side object model. You will want to use Microsoft.SharePoint.Client – Brian P May 16 '13 at 15:45

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.