Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PRM_ServerError in Azure, runs correctly in Emulator

I am trying to do something very simple and getting an error that I have been trying for two days to fix. I have a simple ASP Button calling a function from the codebehind (see below)...and I am receiving the following error. But only when I upload the site to Azure, it runs correctly when emulated.

SCRIPT5007: Unable to get property 'PRM_ServerError' of undefined or null reference 

MicrosoftAjaxWebForms.js, line 5 character 11118

The ASP Button is defined as below, nothing special...

<asp:Button  CausesValidation="false" ID="Button1" runat="server" Text="Login" OnClick="radbtn_loginButton_Click" /> 

The code behind again...crazy simple...

protected void radbtn_loginButton_Click(object sender, EventArgs args)
{
    try
    {
        string uName;
        string uPass;
        uName=UsernameBox.Value;
        uPass=PasswordBox.Value;
        if(uName=="admin" && uPass=="password")
        {
            Response.Redirect("dsxHome.aspx");
        }
        else
        {
            loginMessage.Text="Login Invalid!"; 
        }//end if

    }
    catch
    {
        loginMessage.Text="Problem with Login"; 
    }
 }

The message label is nested within an AjaxPanel...and I am doing other Ajax calls elsewhere in other pages in the site...but the simplest one is breaking....

Any thoughts...I know I have missed something stupid...

Michael

like image 531
Michael Deslongchamps Avatar asked Nov 13 '22 04:11

Michael Deslongchamps


1 Answers

For those interested, the error occurs during ajax calls inside your update panel when some server-side code is called, but the iis app pool has been recycled (which happens after a deployment).

The error can be handled in code by adding the AsyncPostBackError event handler to your ScriptManager.

You can then redirect the user somewhere when this error occurs or display a popup message saying their session has expired and is now refreshed or whatever suits your application.

More info here: https://msdn.microsoft.com/en-us/library/bb398934.aspx

Hope this helps someone :)

like image 121
Scotty Avatar answered Nov 14 '22 23:11

Scotty