简体   繁体   中英

How do I debug a Xamarin app + webapi + SQL Server set-up?

I'm brand new to Xamarin.Forms and Visual Studio (2017 on PC). I'm working with code another (experienced) dev wrote in C# and .NET.

I have a Xamarin app. The app asks me to input data. Then, it saves that data to a SQL Server database via a Web API. Next, later, the app gets that data back from the database to do something.

I can build and publish all projects and the app runs on Android simulator. However, it looks like the data I input is either:

  1. Not sent to the DB
  2. Not used by the DB

I can tell because when I get the data back from the database, the "something" is wrong.

So here's my question: how do I debug that set-up? I'm familiar with debugging my Xamarin app inside VS 2017, but I don't know how to debug the Web API, or how to look inside the database to see if the data I input are recorded correctly.

At this point, I'm not sure where the bug is, or how to find it. Thanks for your help!

Xamarin application:

As you already mentioned, you can debug your Xamarin app in Visual Studio just like you would any other .Net projects.

Web API:

Similarly, you can also debug your Web API project in Visual Studio.

  1. Run the Web API project locally.
  2. Note the address from the address bar and use that in Postman or other similar tools to send/receive the API requests/response.

SQL Server Database:

You cannot technically 'debug' a database, but you can verify the CRUD operations using SQL Server Management Studio (or SSMS ) provided you have the necessary access/credentials.

To find where the error is, I would suggest:

  1. Start from your Xamarin application and verify if the app is sending the JSON as expected;
  2. Then send the same JSON from postman to your Web API and verify if it is accepting/processing the JSON as expected;
  3. And finally, check your database tables in SSMS if the data is stored as expected.

Refer the following links:

https://www.c-sharpcorner.com/article/asp-net-web-api-with-fiddler-and-postman/

https://docs.microsoft.com/en-us/azure/sql-database/sql-database-connect-query-ssms

Hope it helps. Cheers!

Found out you can debug a web API using Visual Studio almost the same way you debug a Xamarin app. Here's a nice tutorial for that:

https://docs.microsoft.com/en-us/azure/app-service/web-sites-dotnet-troubleshoot-visual-studio#remotedebug

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM