Web service method works fine on development computer but failed on server

佐手、 提交于 2019-12-14 00:40:00

问题


I have a serious problem with ASP.NET web service. I have a web service method that checks for the existence of user password in my project's database. I wrote the method inside an asmx file to access to it.

[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;
        }
    }

}

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. I even turned off the Windows Firewall of the server, placed a try..catch bloc (like in the above code) and then tried to test the web service on the localhost of the server by navigating to the web method page (ie. /credentialsvalidationservice.asmx?op=VerifyPasswordExistence), entering test email and password and pressing the Invoke button. Instead of showing an expected result (true or false) (like on my local pc), it jumped into the web service's description page /credentialsvalidationservice.asmx in a new browser tab. I checked the Event Log, and nothing in there. It doesn't give me any error detail to indicate what went wrong. Absolutely nothing in the Event Log.

To give you a bit more information about my project. It's 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 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.

UPDATED: 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. It converted even the name of the web method into lowercase and that caused the problem, because the method name is case sensitive. I just temporarily disabled the rewrite rule to get the service working. The service is placed in the path ~/Services of the root of the web app. I suppose I'll have to find some way to change the rule so that it'll affect only aspx files, but spare all asmx files (especially in the Services folder) from being lowered-case.

来源:https://stackoverflow.com/questions/39314412/web-service-method-works-fine-on-development-computer-but-failed-on-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!