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

john john 961 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

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,348 questions
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,553 questions
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,481 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 65,131 Reputation points
    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 28,291 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 Answers by the question author, which helps users to know the answer solved the author's problem.