Can PCL Libraries work with ASP.NET MVC?

I want to write a library that can work with multiple targets like WPF, Windows Phone / Mobile, Mono and ASP.NET. I keep looking for information on this, but it seems that PCL is not supported in ASP.NET?

Even VS indicates that PCL cannot be used with ASP.NET: enter image description here

So what should I do to write PCL that works on all platforms? Use PCL for everything but ASP.NET and create a regular class library for ASP.NET and basically copy + paste the code?

+3


source to share


1 answer


The short answer is YES, as long as the PCL profile supports the same version of the .NET framework that your MVC application is targeting, you should be fine.

When you create a portable class library, you can choose the combination of platforms your code should run on. The compatibility choices you make when creating the Portable Class Library are translated into a "Profile" identifier that describes which platforms the library supports.

What probably confused you was that ASP.NET was not mentioned in the list of supported software frameworks (platforms). The reason is that ASP.NET is not a software framework, but an application platform (higher level). This means that any application framework that targets the software platform supported by the PCL will also work with the application framework.



Be sure to take extra care when choosing supported platforms when creating a new PCL project, as the API available for use in that project depends on that choice!

Read more about Portable Class Libraries on MSDN .

+8


source







All Articles