5

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

4 Answers4

1

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 :)

Scotty
  • 1,127
  • 1
  • 7
  • 17
0

My two cents, as I also spent a couple of days trying to fix this. In my case it happened due to having CustomErrors set to "On", or "RemoteOnly". AFAIK there is an error happening on the server and the client is trying to show the error, but runs into this PRM_ServerError instead. So basically this problem is hiding an underlying error. To see the underlying error you can just set CustomErrors to "Off"

As a side note, on Chrome the error I got was:

Uncaught TypeError: Cannot read property 'PRM_ServerError' of undefined

Community
  • 1
  • 1
Miguel Hughes
  • 117
  • 12
0

To resolve this issue create or goto global.asax file and add

    void Application_Error(object sender, EventArgs e)
    {
        //direct user to error page 
        Server.Transfer("~/ErrorPages/Oops.aspx");
    }

Add a breakpoint at Server.Transfer("~/ErrorPages/Oops.aspx"); and inspect Server.GetLastError() s result. It returns a Framework exception. Pay attention to inner exceptions which will tell you what is going wrong there.

Stephan Ahlf
  • 3,310
  • 5
  • 39
  • 68
0

I'm chiming in here - hope this helps someone. First for context, we received this error in VS and not Azure or Emulator. Here's how we resolved this same error. Oddly enough, in our situation we were using sessionState mode="SQLServer" So we added :

[Serializable]
public class MySessionClass
{
}

If you want to read more: https://msdn.microsoft.com/en-us/library/ms973893.aspx

Terry H
  • 327
  • 5
  • 11