I have a Web server where users enter their data with the help of a client on android. I made an authorization for this web - server and naturally now it is impossible to enter data from the client without authorization. Question: How can I disable authorization on the Api page, or on the controller (?). Or somehow you can log in when sending data from a client? I did authorization using web forms:
<system.web> <authentication mode="Forms"> <forms loginUrl="MyLogin" timeout="20" defaultUrl="Default.aspx" path="/" > <credentials passwordFormat="Clear"> <user name="Vladimir" password="password" /> </credentials> </forms> </authentication> <authorization> <deny users="?"/> </authorization> The code on the button when authorizing on the web server:
protected void LoginAction_Click(object sender, EventArgs e) { Page.Validate(); if (!Page.IsValid) return; if (FormsAuthentication.Authenticate(UsernameText.Text, PasswordText.Text)) { FormsAuthentication.RedirectFromLoginPage(UsernameText.Text, false); } else { LegendStatus.Text = "Вы неправильно ввели имя пользователя или пароль!"; } } This is how I send the data from the client (can you somehow send the authorization data with it?):
var jsonData = JsonConvert.SerializeObject(user); var request = (HttpWebRequest)WebRequest.Create("Адрес моего веб- сервера/api/User"); var data = Encoding.ASCII.GetBytes(jsonData); request.Method = "POST"; request.ContentType = "application/json"; request.ContentLength = data.Length; using (var stream = request.GetRequestStream()) { stream.Write(data, 0, data.Length); stream.Close(); } var response = (HttpWebResponse)request.GetResponse(); var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
<deny users="?"/>, since this in theory prohibits anonymous access - tym32167