locked
Web service method works fine on development computer but failed on server RRS feed

  • Question

  • User-846417168 posted

    I was intending to reply to a previous thread (link http://forums.asp.net/t/1111790.aspx?Page+Method+Returns+Whole+Page) but it was locked. Anyway I have a similar problem with ASP.NET web service. I have a method that checks for the existence of user password in my database. I wrote a web service method inside an asmx file to access to it.

            [WebMethod]
            [ScriptMethod(ResponseFormat = ResponseFormat.Json)]        
            public Boolean VerifyPasswordExistence(string email, string password)
            {
                EventLogHandlers.WriteToEventLog("Call from WEB SERVICE", EventLogEntryType.Warning);
                //HttpContext.Current.Response.ContentType = "application/json";
                Boolean isValid = PasswordVerifier.checkPasswordExistence_byLoginInfo(
                    UserInfoRetrievingClass.getUsernameByEmail(email), GlobalClass.getMD5Hash(MD5.Create(), password));
    
                return isValid;
            }

    It is supposed to return to me a boolean value. When I tested it on my local computer (Windows 10), it worked fine just as I expected. But when I deployed it to my company's server (Windows Server 2012), it didn't work. I've tried to test the web service on the localhost of the server but it doesn't work either. Everytime I press the Invoke button on the web service method test page, it opens a new browser tab with the web service description page on it, no matter if I change the web method above to public static Boolean or not. In contrast, if I test the web service on the localhost of my dev pc, it'll work fine and give me a boolean value just as I expected when the Invoke button is pressed.

    To give you a bit more information about my project. It was written on Visual Studio 2013 and .NET Framework 4.5.1. The .NET Framework version on both my dev pc and my company's server is 4.5.1. The IIS version on my dev pc (Windows 10) is 10, while the IIS version on the server is 8.5. I wonder do I need to configure the server or install any plugin on the server to get this web service work? Please help. Thanks.

    Wednesday, August 31, 2016 4:07 AM

Answers

  • User-846417168 posted

    Thanks Ailleen. Finally I found the root cause of the issue. It is the URL Rewrite rule that I created for converting all urls of the website to lowercase. Although it's very convenient, it converted even the name of the web method in my web service url into lowercase and that caused the problem, because the method name is case sensitive and must be called 100% exactly correct. I just temporarily disabled the rewrite rule for the service to work properly. I'm trying to figure how how to edit the rule so that it can be used to convert urls of all aspx files, except only web services. The asmx service above is placed in the path ~/Services in the root of the web application. I suppose I'll have to find some way to tell IIS to spare every file in that folder from being lowered-case.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, September 5, 2016 2:10 PM

All replies

  • User-1142886626 posted

    Hi aspnet_dev_2016,

    When I tested it on my local computer (Windows 10), it worked fine just as I expected. But when I deployed it to my company's server (Windows Server 2012), it didn't work.

    You can refer the following link. Hope be helpful to you.

    http://stackoverflow.com/questions/2586003/jquery-ajax-an-asp-net-web-service-works-locally-but-not-remotely

    http://stackoverflow.com/questions/18872782/asmx-webservice-not-working-on-live-server

    https://forums.iis.net/t/1134495.aspx

    Best Regards,

    Ailleen

    Thursday, September 1, 2016 9:29 AM
  • User-846417168 posted

    Ailleen

    Hi aspnet_dev_2016,

    aspnet_dev_2016

    When I tested it on my local computer (Windows 10), it worked fine just as I expected. But when I deployed it to my company's server (Windows Server 2012), it didn't work.

    You can refer the following link. Hope be helpful to you.

    http://stackoverflow.com/questions/2586003/jquery-ajax-an-asp-net-web-service-works-locally-but-not-remotely

    http://stackoverflow.com/questions/18872782/asmx-webservice-not-working-on-live-server

    https://forums.iis.net/t/1134495.aspx

    Best Regards,

    Ailleen

    Hi Ailleen,

    Thanks for your reply. I did what are instructed in those articles but no luck. I even turned off the Windows Firewall on the server but the web service is still not invoked. The problem is it doesn't give me any error detail to indicate what went wrong. I checked the Event Log and nothing in there.

    I even put a try catch bloc in the web method to enforce writing into Event Log if any error happens.  Then I navigated into the method description page /credentialsvalidationservice.asmx?op=VerifyPasswordExistence, input existing email and password and then pressed the Invoke button. Instead of showing an expected result (true or false), it jumped into the web service description page /credentialsvalidationservice.asmx

    Then I checked the Event Log, and nothing in there. Below is the code of the whole class. Please tell me how to solve this problem. Thanks. The deadline of my task is near and I need to fix this by Monday.

        [WebService(Namespace = "http://tempuri.org/")]
        [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
        [System.ComponentModel.ToolboxItem(false)]
    
        // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
        [System.Web.Script.Services.ScriptService]
        public class CredentialsValidationService : System.Web.Services.WebService
        {
    
            [WebMethod]
            [ScriptMethod(ResponseFormat = ResponseFormat.Json)]        
            public Boolean VerifyPasswordExistence(string email, string password)
            {
                try
                {
                    EventLogHandlers.WriteToEventLog("Call from WEB SERVICE", EventLogEntryType.Warning);                
                    Boolean isValid = PasswordVerifier.checkPasswordExistence_byLoginInfo(
                        UserInfoRetrievingClass.getUsernameByEmail(email), GlobalClass.getMD5Hash(MD5.Create(), password));
    
                    return isValid;
                }
                catch (Exception ex)
                {
                    EventLogHandlers.WriteExceptionToEventLog(ex);
                    return false;
                }
            }
    
    
        }
    

    Saturday, September 3, 2016 9:32 AM
  • User-1142886626 posted

    Hi aspnet_dev_2016,

    Inside your event log are nothing, because you didn’t have a successful call to webservice. Firstly, you could set breakpoint in your javascript to check if any errors. Secondly, you could take a look with a web developer tool (press F12 in IE8 or above for example). Then check if the jQuery file’s indeed downloaded or not.

    Following link is about how to use it.

    https://msdn.microsoft.com/en-us/library/gg589512(v=vs.85).aspx

    Best Regards,

    Ailleen

    Monday, September 5, 2016 2:40 AM
  • User-846417168 posted

    Thanks Ailleen. Finally I found the root cause of the issue. It is the URL Rewrite rule that I created for converting all urls of the website to lowercase. Although it's very convenient, it converted even the name of the web method in my web service url into lowercase and that caused the problem, because the method name is case sensitive and must be called 100% exactly correct. I just temporarily disabled the rewrite rule for the service to work properly. I'm trying to figure how how to edit the rule so that it can be used to convert urls of all aspx files, except only web services. The asmx service above is placed in the path ~/Services in the root of the web application. I suppose I'll have to find some way to tell IIS to spare every file in that folder from being lowered-case.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, September 5, 2016 2:10 PM
  • User-1142886626 posted

    Hi aspnet_dev_2016,

    Glad to hear this issue has been solved by yourself. Thanks for your sharing, i will introduce this experience to other forum users who face the same condition. Please mark your reply to close this case.

    Best Regards,

    Ailleen

    Tuesday, September 6, 2016 1:14 AM
  • User-846417168 posted

    Hi aspnet_dev_2016,

    Glad to hear this issue has been solved by yourself. Thanks for your sharing, i will introduce this experience to other forum users who face the same condition. Please mark your reply to close this case.

    Best Regards,

    Ailleen

    Thanks Ailleen. All done.

    Tuesday, September 6, 2016 2:01 AM