Best way to include license in ASP.NET projects

Hi,

I need to use Aspose.Email to send SMTP message. Have a questions regarding setting license:

  • Is it OK to simply put Aspose.Total.lic in Bin sub-folder of the website? My concern is that file content is not encrypted and license can be viewed/copied by anyone having access to the machine. Maybe you have some requirements on license file usage. In WinForms applications I can embed license file directly into application .EXE file

Thanks,
Alex
Hi Alex,

Thank you for your inquiry.

You can put the license file in the Resources folder under your web project and add the following lines of code before calling any functionality of the API.

CODE:

string path = MapPath(".");
path = path.Substring(0, path.LastIndexOf("\\"));
path = path + "\\Resources\\Aspose.Pdf.lic";
// This is how you can get the path to the file.
Aspose.Email.License license = new Aspose.Email.License();
license.SetLicense("Aspose.Email.lic");
// This is how you set the license.

Hi Alex,


You may please encrypt the license file using some encryption scheme with own key as given here. Read the entire license file into string, encrypt it and save it in some file (or may be, this string can be placed in the code). Once the file is encrypted, place this encrypted file on the server machine where site is hosted.

Now in the Application_Start() function of website, read this encrypted string from file and decrypt it. Then copy this decrypted string to MemoryStream and use this memorystream object in the SetLicense() function.

Please give it a try and share the feedback.