How to decompile an asp.net website - c#

I have a website and i can open it with the VS 2010, but it has been compiled, i cannot find the app_code folder and the aspx.cs files. now i wanna see them and make some changes myself. I don't know how.
I know how to do it on a pure dll with the help of the reflector.
Does anyone here help me. Many thanks.

Not sure how you'd modify the compiled asp.net website, but here's how to find the dll's.
In your asp.net site you have for example an file called index.aspx, in your bin Directory there should be a file called something like index.aspx.abcd1234.compiled, open it with Notepad and look for the text assembly="App_Web_y5emcutv", that's the name of the compiled code's dll, just look for that name in your bin directory and open the dll in reflector and look for the ASP namespace.
That's it for the code, it would be rather hard to reverse that into a project file though.

Related

Compilation Error: The type or namespace name could not be found

To start, I have read tons of questions like this but nothing has fixed my issue. When I publish my project from Visual Studio 2013 to a server, I get the following error:
Its apparently missing a reference to a library I'm using. The issue is the dll is getting published (it is in the bin folder on the server). It seems its having some issue finding the reference? I've tried copying the dll and putting it in the same directory as the c sharp code. I've made sure everything is using the same framework. I have no idea what's happening. I need some help. Thanks in advance!
Here is the bin folder:
Here is the folder on the server:
As you can see the project is very small right now.
Here is the Default.aspx code:
Here is the C# code (Default.aspx.cs):
And here is my web.config:
It is because the DbAccess dll is not getting the path
you need to make a folder in your solution and give any name like "ThirdpartyDll".
Paste your dll in this folder and while adding new dll give reference path from this folder and then publish.
On server application will take the same path, which i think you had given from local.
I made the mistake of not formatting the directory on my server using IIS. If anyone comes across this make sure you do that!!!

Looking for missing cs files that are not in dll

So I was brought into this project (C#, asp.net) which is already functional, but I need to edit it. All the source files are compiled, so in order to edit this I need all the aspx.cs files, but whenever I decompile the dll that is supposed to hold them all, I only get some of them. Half of the aspx.cs files are missing. I know for a fact that they should exist, as the site is functional. I have access to the other aspx files as well.
How would I go about finding these remaining missing cs files? Any clues as to where they might be located?

Altering 1 C# controller file

I've worked with PHP but never C#, and I need to make 1 change to a file, and was hoping I could get some guidance, or suggested resources to learn more.
I have 1 cs controller file where I want to change the [Authorize(Roles="A")] to [Authorize(Roles="A,B")]
I made the change but nothing happens, so I've come to the conclusion that this cs file probably needs to be compiled.
The question is, is there a way to compile this one file? Or does the entire site need to be compiled?
When I open the cs files, it opens with "Visual Studio Tools For Application 2.0 2008".
Is this sufficient to make the changes?
My thinking is that one of the following needs to happen:
Scenario 1:
Open the .cs file in the appropriate compiler (of which I do not know
what it is) Compile it and copy the newly compiled file into the
appropriate folder.
Scenario 2:
Open the whole project in a compiler - of which I'm guessing the
".csproj" file to open. Compile the whole project Copy the desired
compiled file to replace the old file.
Scenario 2b:
Open the whole project in a compiler - of which I'm guessing the
".csproj" file to open. Compile the whole project Copy everything
back to the server.
Scenario 3:
The code I have is not sufficient to do the changes, and I need some
other source code.
That's all I've got, if someone can suggestion which one(s) may be on the right track, and how I may go about doing this, it would be greatly appreciated.
Thanks
The fact you are talking about a Controller would strongly suggest you are working on an ASP .NET MVC project. You will have a .sln file which is a solution file which is the master document if you will:
YourWebsiteSolution.sln
YourWebsiteProject.csproj
YourController.cs
Once you open the .sln file with Visual Studio (you need to know what version but you can get the latest here: Download VS2012 Web Express). You can the choose Build -> Build -> ReBuild Solution from the menu and that will re-compile all of your .cs and associated files into DLLs that will be in your \Solution\Project\bin\Debug folder (or Release depending on build).
When you deploy to the server you only deploy the .DLL files (in this instance). You NEVER deploy the actual .cs files as they contain the code and you don't want people peeking into them (this differs from PHP where the code is on the server).
Because you have not changed any of the views you don't need to follow this step but for a full deploy you would also copy any .cshtml or .aspx files and the usual suspects such as .css and .js etc to same folders on server as on the project.
I hope that is a good starter to get you going?

Why does VS2010 allow for the concept of "include in project"?

I'm still learning the basics of how VS2010 sees the world. Apparently, you can optionally "include" a file in a project. I'm a bit confused by this: If a file is version-controlled, AND the file is within the project directory, shouldn't it implicitly be "included" in the project? If not, what's the use case where a version-controlled file in the project directory should NOT be included in the project?
=== Addition ===
Based on the answers I've gotten so far, maybe I should rephrased my question: What does it mean for a file to be "included" in a project?
A project needs to know about files in order for compilation and distribution to occur. Just because you have a file that's under source-control, doesn't mean that it will be compiled if the project is unaware of it.
Also, you may want to include files as part of a distribution package. We do this quite often for our web projects that we distribute using web app gallery.
Conversely, you could have documentation or sql scripts that you version control, but do not want them to be part of the project.
EDIT: In answer to your update, what it means for a file to be included in a project is that the file is actually added to the .csproj or .vbproj file and will be used during compilation and/or distribution. VS does differentiate if the file is Content or if it needs to Compile it. This can be seen by clicking on the file in Solution Explorer and looking at the Build Action property.
No, you don't want random files that happen to be in the project directory included in source control.
We do sometimes put documentation (pdfs) or drawings/schematics in the project folder and under version control but you don't need them inside the visual studio project (especially when they are not being distributed because they are for internal use only).
Excluding the file from your project can be useful if the file is related to the project but not necessarily needed in the solution.
Example
If I need some test XML for an application that i'm writing; that is designed to normally be pulling this from a WCF service, it can be useful to keep that file in the directory for a development environment where I use IO to get the XML for testing, but I don't necessarily want it in my solution which is source controlled.
When you exclude a file from a project is no longer compiled or embedded, then when you want to include it again you can do so without having lost your settings.
If you e.g. copy a file (containing a helpful class which want to have in your project) into a folder of your project, then you will see ... nothing. You have to check the option "Show all files" of the solution explorer and the copied file can be seen, but it is still "greyed out". No you can choose the menuitem Include in project and that file will be integrated in your project and a pending change (add) for your source control is added too. Visual Studio doesn't include all files it can find in the project folder automatically to the project - and that is a good feature.
One of my colleagues explained to me a scenario in which a version-controlled file should NOT be part of the project. Here's the idea:
A developer writes some new code.
The code is experimental, and not intended to be part of the normal build.
The easiest way to exclude the file from the build is to NOT include it in the project, but still version-control it.
This way, the file can be shared with other developers, but not break the build.

Question regrading which files are needed by tessnet2.dll

I made an application for an automated invoice management system for my company. I am using the tessnet2 library for OCR. The whole application works properly on my development machine but as soon as I put the code on the target machine, wihout the development framework, it gives an error of references not found in the .DoOCR method.
I read that you had the same problem and I hope you can help me with it.
I have put the language files in the same directory as the application itself, but its not helping me.
Any help or suggestions will be highly appreciated.
Thanks
Regards
Vin
Look in the VS folder (under Program Files - you'll need to look in sub-folders) for a program called "Depends". This looks for dependencies from EXE and DLL files. Run it with the DLL as a command-line parameter, and that should list what files are needed by that DLL. Then see if they are all present on the destination system.

Categories

Resources