Reputation: 191
I have a "User" class in both my Web App and my Webservice.
Everything works and I get data back but when I assign the User class in my Web App that of the Web Service then it cannot convert between the two
How I call it in my web app
User user = new User();
user = userService.Login(UserName.Text, Password.Text); // Here it says it can't convert
how I send it from my web service
[WebMethod]
public User Login (string userName, string Password)
{
UserData usrData = new UserData();
return usrData.UserExists(userName, Password);
}
And what my class looks like in both the Web App and the Web Service
[Serializable]
public class User
{
/// <summary>
/// User Id
/// </summary>
public int ID { get; set; }
/// <summary>
/// User Name
/// </summary>
public string Name { get; set; }
/// <summary>
/// User Surname
/// </summary>
public string Surname { get; set; }
/// <summary>
/// User Email
/// </summary>
public string Email { get; set; }
/// <summary>
/// User Password
/// </summary>
public string Password { get; set; }
}
Upvotes: 0
Views: 79
Reputation: 32718
So you're trying to call it from C# code? Simply do this...
User user = userService.Login(UserName.Text, Password.Text);
If you're calling it from the server side, you can remove the [WebMethod]
attribute. You don't even need a Web Service for this, assuming userService
is of type UserService
, just place the UserService.cs
class inside your App_Code
folder. Or better yet, place UserService
class in a class library, and add a reference in your web application to that library.
Upvotes: 1