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

john john 831 Reputation points

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?


A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,159 questions
A set of technologies in the .NET Framework for building web applications and XML web services.
3,577 questions
A Microsoft web application framework that implements the model-view-controller (MVC) design pattern.
988 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Bruce ( 44,621 Reputation points

    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 24,391 Reputation points

    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