decompiling an asp.net site - asp.net

hallo all
i have an asp.net site which i have no source code for it.
anyway i would like to decompile the whole site and that way i can work on it agian.
how can i decompile an entire website easily to c# and not do it file by file with feflactor?
please help me with this, thank you!

You can use the File Disassembler plugin for Reflector. It'll let you dump out a whole assembly into code files all at once.
There's another plugin: FileGenerator, that looks like it'll do the same thing, and generate a project file for you to boot.

I have used Decompiler.NET in the past. It does a very nice job.
Decompiler.NET
Hopefully you have permission to Decompile this code.

In the time passed a number of new and much better options became available. JustDecompile and DotPeek are up to date free decompilers that are definitely up to the task of decompiling and asp.net site.
ILSpy should also be capable of doing this although it seems work on keeping it up to date is slowly coming to an end. dnSpy is a more obscure alternative for assemblies that have been somehow processed/modified after compilation, e.g. by obfuscator or IL optimizer, etc.

Related

How to document a file that is not in a solution?

I have a need to document methods/functions in *.cpp code files that are not part of a .NET solution. Up until now my workaround has been to create a solution, but this is a time consuming step for all the different files I come across.
Does anyone know how this can be accomplished?
Scott,
Unfortunately, this is the workaround that you have to use as long as GhostDoc relies on some of the information from Visual Studio CodeDOM... The CodeDOM does not provide any info when you open just a single file.
Do you mind me asking if there is particular reason you are opening single file in VS? Other that these might be random files that are not part of a solution?
Thanks!

Automating finding compile errors in ASP.NET pages

I have an ASP.NET website where the pages call a few components in DLLs. I need to change the signature of a method in the component, and short of doing a text search, don't know if this will break any pages or not. IMO, this is the weakness of web programming -- you don't get the benefit of a compiler telling you about syntax errors.
But it doesn't need to be so. Does anyone know if there is a way to run a spider over a website watching for compile errors, or perhaps some tool that would compile all the .aspx files in a folder structure looking for compile errors?
This is merely for syntax checking -- not to actually pre-compile the website.
EDIT It looks like aspnet_compiler is being recommended. I don't use Visual Studio projects for the website -- it's grown over time with my own templating system (back before Master Pages were available). So something that would run aspnet_compiler over all the files in a folder might work...
There is a flag that you can put on your project that tells it to compile all the aspx files when the project is compiled. It adds time to your build, but it can sometimes be worthwhile. See http://mikehadlow.blogspot.com/2008/05/compiling-aspx-templates-using.html
Also, Resharper is really good at finding references to methods, even in aspx files. So if you use Resharper to rename a method, as long as your solution includes the web project, it'll find and rename that method in the aspx files, too.
This is one of the many reasons we use development tools like Visual Studio in the first place. The single easiest way to do what you're asking is to develop with an IDE that DOES compile and check for errors, even ifyou choose to publish teh un-compiled code.
Since Microsoft offers Visual Web Developer for free, there's really no reason to NOT use it.
The compiler will automatically catch and any report any errors in your .cs source or code-behind pages. Your assumption that the compiler won't catch syntax errors (such as getting the arguments in the wrong order when calling a method, etc) is incorrect - that's one of the primary benefits of using a compiled language. If you're experiencing something that contradicts this, please post some code.
If you're concerned about errors in the ASPX files or in your views (if using MVC), you can have the IDE precompile ASPX files, as well.
See this article for more information.
I turn this off most of the time since it slows down compilation, but I use it before deploying a site as an extra verification step.

Possible to turn off App_Code auto-compile?

Working with Visual Studio (I'm using 2008) I have started to notice that when you save a file in the /App_Code folder, the program will hang for a bit before returning control. After a bit of research, I have learned that there's an auto-compile feature at work, which I assume is what is slowing down my system.
So the question is this: Is it possible to turn off the automatic compiling of files in the /App_Code folder? Or, even better, is there a way to reduce the time that it takes, or make it work a little more smoothly in the background? Any thoughts/ideas are appreciated!
Sorry i don't know of any way of switching off compiling the app_code folder. If its an issue I would try to keep the amount of files in this directory down to a min or even move them out to a seperate library.
ScottGu has some good tips that you might find useful.
https://weblogs.asp.net/scottgu/Tip_2F00_Trick_3A00_-Optimizing-ASPNET-20-Web-Project-Build-Performance-with-VS-2005
No you can't turn off app_code folder.

Pre-compiled over source code - how can I reverse engineer it?

Is there a way to reverse engineer a pre-compiled website .... if for example someone 8) was silly enough to publish their site to a virtual directory witha local path set to the project folder in VS2008?
Help :)
Reflector is difficult to use with a precompiled site because of the way it breaks up the pages. It is not always clear and not an easy way to reverse engineer.
In fact, one of the main reasons we precompile sites is becuase it is harder to reverse engineer and update production code.
You should be able to use Reflector to see the source code. There are plugins which will decompile an assembly (.DLL or .EXE) created with .NET into a new Visual Studio project.
I had the similar issue and used Reflector to Decompile it. I got the source code, then changed the bit I wanted, and rebuild it. Then I copied that dll again to Production site. It started to reflect my changes. It was very easy and not at all difficult, maybe because Precompiled site had dlls for every page, and was updatable , so had only code-behind file in dll.
For reference: http://www.reflector.net/

How to package an ASP.NET application to prevent customers from modifying it?

Is there a tool or some general approach to packaging all the files of an ASP.NET application into binary form to prevent modification once its deployed? I am thinking there would be a set of signed binaries and a config file for settings that we allow the customer to modify. Has anyone attempted this, is it even possible?
I would pay a reasonable amount for a slick commercial product that did this with minimal hassle.
UPDATE
Sorry, from the answers I can see that I wasn't clear. I meant literally packaging ALL files, not just the code files. This means aspx, scripts, images etc. I'm not trying to prevent reverse engineering... this is a supportability issue, i.e. to avoid dealing with problems brought about by customer messing with the files.
If you made a web application project than you can compile your code into a single dll file. You can find it in the bin folder.
Just use aspnet_compiler.exe to precomple everything and then use aspnet_merge.exe to roll up all of the compiled assemblies into a single assembly. You can use an obfuscation tool like DotFuscator if you want to make it more difficult to reverse-engineer. Visual Studio pro and up include a "lite" edition of Dotfuscator that you can use for this.
Your codebehind files will be compiled in a single dll as ZippyV already mentioned. The aspx files will get deployed normally on the webserver.
But still, your dll files can be disassembled quite easily. So to be sure you have to use an obfuscator.
If you mean ALL files including the aspx you could also consider ngen. It precompiles everything into a dll so you can't even get at the aspx pages.
Although, ngen was designed to get rid of the JIT compiling feature of the framework and is definitely not a generally recommended approach but it may work in your case well.
From VS2008 select the menu option "Tools" and then "Dotfuscator Community Edition". You will have a "Learn More" link after it starts up.
I also sign mine using SN.exe to make it have a strong name. Given all this, I think it is complicated enough to figure out a system if you are given the source code and help.... so I don't worry about it anymore.
maybe Dotfuscator your customer won't be able to modify it nor reverse-engineer it :)

Resources