1

I need to protect an Asp.Net Web Api 2.2 application using Portable.Licensing. I have organized the application by creating multiple Asp.Net Areas. Ex:

  1. Core
  2. Accounting
  3. Human Resource
  4. Inventory

I need to licence each and every Areas. If customer has purchased the Accounting module, then only he should be able to access the Accounting functionality. Otherwise I have to display an error message.

And also I would like to generate a unlike machine key to protect software from piracy.

So how can I use portable licensing with Asp.Net Areas? Where/At which point the license needs to be validated?

Could any one please help me to achieve my requirement by providing some instructions? Providing sample code is highly appreciated!.

Rahul
  • 2,431
  • 3
  • 35
  • 77

1 Answers1

3

For everyone wandering about same thing:

Well, basically, how to implement licensing in your application - it depends! No silver bullet, as always.

I spent half of a day studying Portable.Licensing and that's what comes into my mind: In Portable.Licensing you have "WithProductFeatures" method in fluent api for adding custom data to license, and your Areas is just it - product features. But where to insert check for it - depends on number of factors:

  1. How much do you care for solution performance?
  2. How much do you care for people just cracking IL?

If you care more about performance then about people changing assemblies easily and getting cracked version - you can save Available Feature data from license to some cache and access it in:

  • Every method of WebApi controller
  • Basic controller for your WebApi Controllers (OnActionExecuting is a good candidate)
  • In Filter for WebApi (here is some nice example)

And if you consider trying harder to protect your code - spread license data checking calls across these places, and add them using Fody (i am just planning on implementing it, so no code sample - just library reference here) - don't make life of pirates as easy as changing IL of 1 method :)

Fildrance
  • 56
  • 4