0

I am developping an asp.net application. When an user clicks on a button, he calls a webservice passing also the parameter he has before entered in a textfield. When the webservice returns no results, it displays a popup, everything works well in local, but when I deploy my application on my windows server, the pop up is not displayed. This is my code:

        if (!string.IsNullOrEmpty(textbox.text))
        {
            try
            {
               //webservice call
               string result = webservice.function(textbox.text);
            }
            catch (SoapException ex)
            {
                Utils.Log_File(ex.Message);
                Utils.Log_File(ex.StackTrace);
                string message = ex.Message;
                //this popup is not working on the deployed application
                Page.ClientScript.RegisterClientScriptBlock(GetType(), "error from code behind", string.Format("alert('{0}')", message), true);
            }
        }

I debug my code from client side in chrome to see the error. When I debug the localhost everything works well, the popup from soapexception is displayed with this message '[E_E1] [Parameter NotFound]'

When I debug the server app, I am getting this error in chrome console :

<script type="text/javascript">
//<![CDATA[
alert('System.Web.Services.Protocols.SoapException: [E_E1] [Parameter NotFound]
    [uncaught syntaxerror unexpected token illegal]
....
user2443476
  • 1,935
  • 9
  • 37
  • 66
  • Is it possible that the call to Utils.Log_File results in an error when not running locally? – Emil Lundin Nov 24 '14 at 09:57
  • Did not think to that, I will try it and tell you. – user2443476 Nov 24 '14 at 10:00
  • Emil, I change the code by putting the generation of the message before the utils.log_file and it didn't change anything. – user2443476 Nov 24 '14 at 10:13
  • I also add some informations on my bug. – user2443476 Nov 24 '14 at 10:21
  • See this answer for an explanation of the error you're getting. http://stackoverflow.com/questions/12719859/syntaxerror-unexpected-token-illegal Still doesn't explain why it works locally though. I hope you find the cause. :) – Emil Lundin Nov 24 '14 at 12:12
  • Thanks I understand that's because of the message value. But I can't understand why the message value is different on the local app from the server app. – user2443476 Nov 24 '14 at 12:36

1 Answers1

-1

Try using ClientScript.RegisterStartupScript(this.GetType(), "Error", "alert('"+MailMessage+"');");