In a SharePoint Hosted app, the Default.aspx page is "wrapped" in the webform of id="aspnetForm". In my AngularJS app that lives on that page, every time I put a form tag into my Angular code, SP2013 strips it out.

As you not supposed to use forms in SP-Hosted apps?

3 Answers 3


It's not a sharepoint issue, it's an ASP.Net issue. ASP.Net only allows one form. Yes, this is bizarre to folks who are new to it, but that's the way it works and has worked for over a decade now. So, perhaps:

  • Redo your logic to work with one form.
  • Put your custom functionality outside of the ASP.Net form
  • Use javascript to move your form outside of the ASP.Net form

Or, as another possibility, I don't know if it's required to use an ASP.Net form for SharePoint hosted apps? Anyone else know that? (It isn't required for a provider hosted app.)

  • 1
    index.html will work just fine
    – eirikb
    Commented May 1, 2014 at 14:10
  • I was building the app using index.html but discovered that _spPageContextInfo is not available. This app NEEDS to get the current_user and check it against a list to see if they are authorized and I can't get the current_user in JSOM without that "service" and it is only available to me if I use the MasterPage ... so I think (I was told) that I need to use the Default.aspx and then struggle with the forms ... this app has more than 20 forms and each of them are getting stripped out as "illegally nested"
    – jgravois
    Commented May 1, 2014 at 15:13
  • Is there a programmatic way to "close" the aspnetForm? I am not using anything like PostBack.
    – jgravois
    Commented May 1, 2014 at 15:19
  • Close? I don't know what you mean. But, the asp.net restriction on forms is that there can only be one server side form (runat=server)(well, one server side form that is visible at a time), and that form cannot contain additional forms inside of it. You can have multiple non-server side forms, just add them above or below the server-side form tag. You just won't be able to use server-side controls in those forms.
    – Mike2500
    Commented May 1, 2014 at 15:32
  • What I meant was to add a closing form tag to close that runat=server form. In a SharePoint-hosted app, we have no access to the MasterPage and our entire workarea is within that form so I don't see how I could put my app above or below the all-encompassing form.
    – jgravois
    Commented May 1, 2014 at 15:39

You can use an AngularJS form inside the SharePoint Default.aspx page. Instead of using

<form name="formName">


<ng-form name="formName">

By doing this, ASP.NET will not see an embedded form tag, and therefore will not remove it.


Another option, which has worked well for me:

  1. Create an new page in your Site Pages library.
  2. In that page, add a Content Editor Web Part.
  3. Point that Content Editor Web Part to your index.html page, using the "Content Link" property on the Properties panel.

This will display your app as a Web Part on a SharePoint page. It can be the only Web Part, or you can add additional Web Parts around it if you wish.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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