Note that there are some explanatory texts on larger screens.

plurals
  1. POMethod called infinite times in Web Service
    text
    copied!<p>For my class on Web Services I am trying to create an EXTREMELY simple login system. I ham having a problem where createAccounts() keeps getting infinite times whenever checkCredentials is called. Any idea why?</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; using System.ServiceModel; using System.ServiceModel.Web; using System.Text; using System.IO; public class Service : IService { static String path = @"PATH REMOVED"; List&lt;Account&gt; accounts = new List&lt;Account&gt;(); StreamWriter sw = null; private void createAccounts() { String data = File.ReadAllText(path); string[] data2 = data.Split(new string[] { Environment.NewLine }, StringSplitOptions.None); string[] temp; for (int i = 0; i &lt; data2.Length; i++) { temp = data2[i].Split(','); if(!usernameExists(temp[0]) &amp;&amp; temp[0] != "") { accounts.Add(new Account(temp[0],temp[1])); } } } public bool CreateAccount(String username, String password) { createAccounts(); sw = File.AppendText(path); if (!usernameExists(username)) { sw.WriteLine(username + "," + password + "\n"); sw.Close(); sw = null; return true; } else { sw.Close(); sw = null; return false; } } public bool usernameExists(String username) { createAccounts(); if(accounts.Exists(a =&gt; a.username == username)) return true; else return false; } public bool CheckCredentials(String username, String password) { createAccounts(); if (usernameExists(username)) { if(accounts.Find(a =&gt; a.username == username).username == username &amp;&amp; accounts.Find(a =&gt; a.username == username).password == password) return true; else return false; } else return false; } } class Account { public String username; public String password; public Account(String u, String p) { username = u; password = p; } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload