Get source code of my published ASP.NET website from server
Asked Answered
R

2

8

I've published my ASP.NET website to my Windows Server 2012 via Visual Studio.

But things happened, and I lost all of my sources. I had a backup but it is not recent enough. I could re-code everything that is missing but I don't remember all of it.

I was wondering if it's possible to get the source code from the server where I published my website ? I have a full access on it.

Thanks,

Hellcat8

Railroad answered 6/1, 2017 at 11:15 Comment(4)
This depends a bit on how exactly you deployed; have you looked in the directory to see what you have? is it just dlls? dlls plus views? everything?Meyeroff
Don't you have a repo? .. you maybe can try with a reverse engineering software from your dll'sBackfire
I've looked in the directory (wwwroot/sitename) and I've got all the files, except that there is no "aspx.cs", only "aspx" files. And I need .cs files. And I used the publish feature of Visual Studio.Railroad
yeah, you'll need to decompile them, thenMeyeroff
K
13

Sorry to hear that!
An ASP.NET (WebForms) application consists of code-behind classes and .aspx pages. All the code-behind classes are compiled into a class library located in the bin folder in the root directory.
An ASP.NET (MVC) application has a similar structure, but with views instead with the .cshtml / .vbhtml extension(s).

If you've lost the back-end code for the application, you'll need to decompile the dll file to obtain your code back. Sadly, you'll lose all of the code comments so they'll need to be re-created.

Some decompilers: dotPeek, ILSpy, JustDecompile, Reflector

Kurdish answered 6/1, 2017 at 11:21 Comment(3)
It's a WebForms application. I can see on the server all of the aspx files but not the aspx.cs. And thanks, I'll give them a try as well.Railroad
The code-behind (.aspx.cs) files are the ones which are compiled into the dll in the bin folder. Run one of the decompilers on that file and you'll be able to view the C# code.Kurdish
I used dotPeek to decompile my .dll file. It's perfect, thanks a lot.Railroad
B
5

I think that if you don't have a Repository or something similar but ONLY DLL's you can try with a Reverse enginnering tools...like:

http://www.red-gate.com/products/dotnet-development/reflector/
Backfire answered 6/1, 2017 at 11:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.