Base solution for your next web application
Open Closed

How can I call webserivce on this login verification #3587


User avatar
0
kunnummal created

Hi,

I used webservice in asp.net boiler plate application(Login verification purpose). That webservice check the tenant name,user and password if success and return login based on tenantId. This webservice i called one application that time i am getting this error "SoapException was unhandled". Please check my Code and give some tips (or) example [WebMethod] public async Task<int> GetTenantId(string strTenancy, string strUser, string strPwd) { int tentId = await GetLoginResult(strTenancy, strUser, strPwd); return tentId; }

    private async Task&lt;int&gt; GetLoginResult(string strTenancy, string strUser, string strPassword)
    {

        string strRetVal = "";
        int TId = 0;
        try
        {
            var loginResult = await _logInManager.LoginAsync(strUser, strPassword, strTenancy);
            switch (loginResult.Result)
            {
                case AbpLoginResultType.Success:
                    return loginResult.Tenant.Id;
                default:
                    return TId;
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
}

[b]Here I am calling webservice[/b] LoginSample.LoginSample obj = new LoginSample.LoginSample(); var n = obj.GetTenantId(strTen, strUser, strPwd);

Please give some suggestions. Thanks


3 Answer(s)
  • User Avatar
    0
    alper created
    Support Team

    you need to modify your config file:

    <system.net>
       <settings>
            <httpWebRequest useUnsafeHeaderParsing="true" />
       </settings>
    </system.net>
    

    Check out the issue on this link <a class="postlink" href="https://social.msdn.microsoft.com/Forums/en-US/2e3be101-b9c1-4b0d-a631-b840af1cdfc3/protocol-violation-can-i-change-how-sensible-the-test-shall-be-to-protocol-errors?forum=vststest">https://social.msdn.microsoft.com/Forum ... m=vststest</a>

  • User Avatar
    0
    kunnummal created

    Not working still i am getting same error. Please check the webservice method I thing that this the problem. Please check

    public class LoginSample : System.Web.Services.WebService { private readonly LogInManager _logInManager;

        public LoginSample(
           LogInManager logInManager)
        {
            _logInManager = logInManager;
        }
    
        [WebMethod]
        public async Task&lt;int&gt; GetTenantId(string strTenancy, string strUser, string strPwd)
        {
            int tentId = await GetLoginResult(strTenancy, strUser, strPwd);
            return tentId;
        }
    
        private async Task&lt;int&gt; GetLoginResult(string strTenancy, string strUser, string strPassword)
        {
    
            string strRetVal = "";
            int TId = 0;
            try
            {
                var loginResult = await _logInManager.LoginAsync(strUser, strPassword, strTenancy);
                switch (loginResult.Result)
                {
                    case AbpLoginResultType.Success:
                        return loginResult.Tenant.Id;
                    default:
                        return TId;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
    

    Please check the code.

    Thanks

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @kunnummal,

    Do you have any detailed error message about this problem. Becasue it is hard to find reason of problem without an error message.

    I suggest you to first catch error message. If the error occurs in AspNet Zero side, you can check Logs.txt file or you can check windows event viewer.

    Thanks.