Share the buisness logic between ASP.NET core web application and Xamarin

john john 1,026 Reputation points
2023-08-29T01:06:48.2233333+00:00

We want to build a web application using ASP.NET MVC and mobile app using Xamarin. But I am not sure how we can share the business logic between the 2 projects (Web Application and the Mobile app)?

I usually build web applications using ASP.NET core MVC, but never share the business logic of this web application with a mobile application.. so can anyone advice on the appraoch i need/can follow to share the logic between the web application and the mobile application?

Thanks

Developer technologies | .NET | Xamarin
Developer technologies | ASP.NET | ASP.NET Core
Developer technologies | ASP.NET | Other
{count} votes

2 answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 81,981 Reputation points Volunteer Moderator
    2023-08-29T15:25:11.6733333+00:00

    To share code between Xamarin and another project you move the shared code to its own library. This library must a .net standard 2.0 library. Then reference this library from both projects.

    You may need to think about abstracting data access in the library as the apps may have different access to data.

    1 person found this answer helpful.
    0 comments No comments

  2. AgaveJoe 30,406 Reputation points
    2023-08-29T11:54:14.8533333+00:00

    i mean to share the business logic inside the Controllers between the web project and the mobile app project..

    Web API is the modern ASP.NET solution for sharing data across different clients.

    If the MVC controllers already exist and contain business logic then you'll want to move the business logic to an application layer (DLL) that your project can share can share.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.