Hi everyone @Limitless Technology and @MotoX80
I found the solution,
I searched deeper in dev-tools for the error and found -
InvalidOperationException: Only web services with the [ScriptService] attribute in the class definition can be read from a script.
Than I searched for it and found the solution so I added in C# the Attribute Class [ScriptService] to WebService.cs
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService]
I changed the fetch method to work -
fetch('http://localhost:50496/WebService.asmx/SignUp', {
body: JSON.stringify(data),
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
})
.then((response) => response.json())
.then((userData) => {
if (userData.d && userData.d.length > 0) {
console.log('userData', userData);
let user = JSON.parse(userData.d);
setUserData(user);
history.push('/');
} else {
console.log('error not good');
}
})
.catch((err) => {
console.log('err', err);
});
and now it's working great.
Thanks.