ASP.NET Webform scriptmanager compatibility issue with Office outlook web add-in RRS feed

  • Question

  • We use webform to develop our outlook web add-in.

    There has been an issue in the add-in when a postback occurs inside an updatepanel, some client side errors will be thrown and it will make the add-in malfuntion. This issue is quite intermittent and we never found a solution.

    One of the error is like this "h is not a constructor"

    I have managed to strip down the add-in to its most simple form possible, where only the office.js and the scriptmanager are present. It can be observed that if the button is hit, a postback occurs and there is some chance that an error is thrown:

    Uncaught TypeError: Cannot read property 'PageRequestManager' of undefined
        at Sys._Application.dispose (VM7863 ScriptResource.axd:5)
        at Sys._Application._unloadHandler (VM7863 ScriptResource.axd:5)
        at VM7863 ScriptResource.axd:5
        at b (VM7863 ScriptResource.axd:5)

    Interestingly this will only happen in the outlook context. When the same structure is used outside of outlook, there will be no error. It seems like the scripmanage's  injected Javascript is conflicting with office.js or the outlook enviroment or both. But I cannot really get the answer/solution.

    Here is my sample code:

    <%@ page language="C#" debug="true" autoeventwireup="true" codebehind="Index.aspx.cs" inherits="test.Index" %>
    <%@ register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>
    <!DOCTYPE html>
    <head runat="server">
    	<meta charset="UTF-8">
    	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
    	<!-- For the JavaScript APIs for Office, go to to learn more. -->
    	<script src="" type="text/javascript"></script>
    	<h4>Sample APP to replicate the scripte manager issue</h4>
    	<form id="form" runat="server">
    		<asp:scriptmanager id="ScriptManager" runat="server" scriptmode="Release" asyncpostbacktimeout="300" />
    		<asp:button id="button" runat="server" text="Click Me!" />
    		Office.initialize = function () { };
    		var prm = Sys.WebForms.PageRequestManager.getInstance();

    I can also zip the sample app if it helps, it is very simple anyway.

    I have only found one similar issue on the web but it does not really help:

    • Edited by Frostless Thursday, January 30, 2020 11:42 AM
    Thursday, January 30, 2020 11:37 AM

All replies

  • The current work around is to put the office.js reference after the scriptmanager control. Essentially what it does is to make sure that the scripts generated by scriptmanager will be loaded/executed before office.js.

    <asp:scriptmanager id="ScriptManager" runat="server" scriptmode="Release" onasyncpostbackerror="ScriptManager_AsyncPostBackError" asyncpostbacktimeout="300" />
    <!-- For the JavaScript APIs for Office, go to to learn more. -->
    <script src="" type="text/javascript"></script>

    Have a look at the source of the office.js. Seems like it has some referece relating to the ajax stuff (Sys, MicrosoftAjax.js etc) That might be the problem.

    • Edited by Frostless Tuesday, February 11, 2020 3:58 AM
    Tuesday, February 11, 2020 3:56 AM