I am calling my web service from angularjs
this is my code
$http.get('loginservice.asmx/validatelogin', {
params: {
username: $scope.txtlogin,
password: $scope.txtpass
}
})
.then(function (response) {
alert('login success');
})
this is my path when i drag and drop the web service
<a href="~/loginservice.asmx">~/loginservice.asmx</a>
but when i click on login button
I am getting error and this is how my path look like
/login/~/loginservice.asmx/validatelogin?password=123&username=minesh
the error is (the resource file cannot be found)
my web service
using System.Web.Services;
using System.Web.Script.Serialization;
using System.Web.Script.Services;
using System.Data.SqlClient;
using TaskManager.App_Code;
namespace MVC5TMS
{
/// <summary>
/// Summary description for loginservice
/// </summary>
[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 loginservice : System.Web.Services.WebService
{
DbFunction dbf = new DbFunction();
Crypto cry = new Crypto();
JavaScriptSerializer js = new JavaScriptSerializer();
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
[WebMethod]
[ScriptMethod(UseHttpGet =true)]
public void validatelogin(string username, string password)
{
SqlCommand cmd = new SqlCommand();
cmd.Parameters.AddWithValue("@LoginName", username);
cmd.Parameters.AddWithValue("@Password", cry.Encrypt(password));
cmd.Parameters.AddWithValue("@Prompt", "SELECT");
SqlDataReader reader = dbf.ExecuteSP_Reader("User_SIDU", cmd);
if (reader.Read())
{
Context.Response.Write("success");
reader.Close();
}
else
{
Context.Response.Write("fail");
reader.Close();
}
reader.Close();
}
}
}
what is wrong here?