Click here to Skip to main content
15,886,258 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello
The following Code works on another part, but here when the postasync it is executed its return to the try again and again. Any Help pls?
C#
#if DEBUG
	HttpClientHandler insecureHandler = DependencyService.Get<ihttpclienthandlerservice>().GetInsecureHandler();
	HttpClient client = new HttpClient(insecureHandler);
#else
	HttpClient client = new HttpClient();
#endif
	var data = new FormUrlEncodedContent(new[]
	{
		new KeyValuePair<string, string="">("FechaRegistro",  p0),    
		new KeyValuePair<string, string="">("TipoGasto", p2),
		});
	try
	{
		string url = "https://10.0.2.2:7254/api/PostData/postTransacciones";       
		client.BaseAddress = new Uri(url);
		var response = await client.PostAsync(url, data); 
		if (response.IsSuccessStatusCode)
// incomplete


What I have tried:

I had checked Api Manual, c# tutorial and other part of my app where it is working
Posted
Updated 22-May-23 4:07am
v2
Comments
Graeme_Grant 19-May-23 23:48pm    
What is the exception telling you? The answer will be there! Post usually requires authentication first.
Luis M. Rojas 20-May-23 15:28pm    
Nothing, never get there, only try.. postasync, try and postasync
Richard Deeming 22-May-23 3:36am    
That would suggest you're trying to post from an action to itself recursively.

1 solution

The only solution was to insert the in the button_click even.
Why? I do not know.
 
Share this answer
 
Comments
Richard Deeming 23-May-23 3:42am    
Since you've not explained your solution clearly, nobody else knows either. Insert the what in the button_click event?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900