Aug 31, 2009

How to publish asp.net web application and protect its source code

How to publish asp.net web application and protect its source code

by admin on August 4, 2009

Sometimes you need to deploy your web application whilst protecting your source code. In that case, you can compile the code into a single .dll file. Please note that only code files (such as .vb and .cs) can be compiled, not the markup files (aspx, ascx, etc).

In order to get it to work, you need to perform few steps.

Step 1: Open solution with your web application and build (”Build > Build ProjectName” menu”)

Step 2: Open Solution Explorer (”View > Solution Explorer” menu). Right click your web project node. Select “Publish“. Although you can publish to different locations, it would be more flexible to publish the project into local directory on the hard drive. This way you can obfuscate your dll before the actual publishing. Type relative (e.g. “mypublishdir”) or absolute (”C:programmingmypublishdir”) path and click “Publish”.

Step 3 (optional): In case if you need additional protection for your source code, you can obfuscate the dll now. Navigate to a folder with the published files, then “bin” and obfuscate the dll file as needed. I prefer Eazfuscator.NET for obfuscation, since it’s free and easy to use. You don’t need to obfuscate other files. Obfuscation makes it difficult for someone to extract source code from your dll.

Step 4: Upload all received files to your webserver via FTP, webmanager or Remote Desktop.

Done!

1 comment: