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
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
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/
Related
I realize my question may be something stupid. But here is the problem:
Ive got an ASP.NET MVC web application, it already compiled and it works on the web host. So it has no *.cs files (as I understand they turned into dlls), and clearly it has no *.sln file. I want to run this application using Visual Studio 17, and try to debug it(to see the real code working and get something useful for myself) is it possible? If yes, then please, tell me how to do this. I'd like to google it and find out, but I don`t even understand what to look for.
Thank you in advance.
You can to use Disassembler only for view a namespaces and clases, but not all the code.
I took over a web application project that reference dlls. The solution has the actual project as well as the class libraries used to create the DLL. I need to make changes to the web application and deploy to production. I'm use to deploying asp.net website as well as classic asp which was very straight forward, Just copy the files.
I need help to understand the compilation and deployment process. Here is some questions:
1) Class library(DLL) changed; do I just compile that class library project and move the Dll only.
2) Web application project changed and the dll stayed the same; what files do I move.
Also, if someone can clarify how DLLs version are handled when deployed. I'm use to the old way of unregistering /registering the DLLs and this is not the case right now. I'm worried about having multiple copies of the DLL on the same box.
Any help or reading reference would be appreciated.
Jamal
When you are manually deploying in that fashion it is very easy to make a mistake (forget to copy a related file). It's happened to me before.
I recommend that you make use of the publish feature in Visual Studio.
You can right click on the web app and from the context menu select 'Publish'. I normally publish to a local folder (You could publish to your server directly) and then use an FTP client such as FileZilla to actually deploy ( I've had some issues deploying directly from Visual Studio).
When you upload using FileZilla you can specify how you wish to handle existing file overwrites.
I use the option: 'Overwrite if source file newer'. That way deployment is fast (only the files that have changed are depoyed) and safe as we cannot miss a file.
To answer your questions:
1) yes, it is sufficient to deploy the class library but only if it remains binary compatible with the old one (Easy to make mistakes here).
2) You need to deploy the files that changed (dll's, aspx, cshtml, etc...). If the class library dll's have not changed you do not need to redeploy them.
Follow the steps above and you should be fine.
It sounds like you're talking about a precompiled .net application. The app is compiled using Aspnet_compiler.exe, and the new DLLs are copied to the host.
The DLLs don't have to be registered, IIS "knows" what to do with a precompiled .net app. It's pretty much just drop-and-go; not unlike copying the .aspx files directly.
You are able to update a subset of the DLLs (e.g., the class library). There are several modes available that allow you to compile all or part of the application.
When you change a DLL, often times you can just drop it right in assuming you aren't referencing by a specific version number. Generally to be on the safe side, I copy the entire website out again when changing DLLs. Its not strictly necessary, but its probably the easiest method if your website isn't too large.
If you're changing a file that is not deployed in its compiled form (.aspx, .aspx.cs, .cs files in the App_Code folder) you can just update that specific file and restart IIS for good measure.
Generally speaking, if a dependent assembly changed you can just deploy the new assembly. However, if ANY of the interfaces to that assembly changed OR there are other corresponding changes to the web application then you'll have to deploy the whole thing.
That said, I've seen shops that require a full recompile, deployment, and testing even if just one line of code inside a dependent assembly changed.
The full deployment part is pretty easy.
Right click on the web project and click Publish.
Publish either directly to the web server (I don't recommend this) or publish it to a local directory.
Make any config changes necessary for the production push.
If you publish to a local directory, copy the compiled files to your production server.
Some people say to delete the production files first, then copy. Others say copy to a new directory and repoint IIS to the new directory. You'll have to see what works for you.
Now, one thing web apps give you is config transformations. This means that you can let the compiler make config changes depending on the environment you are publishing to. I highly recommend you research and use these. It makes bad pushes much less likely.
I always thought that when you dropped a control onto an .aspx page that a declaration of that control ended up being generated for you (either in a designer file, or within your code behind). All of the apps I have worked on have worked this way.
A coworker of mine was installing resharper and it was showing that all her code behind pages would not build. Turned out that resharper could not find a definition for any control that she has dropped onto her markup. She has no designer files, and no declarations in markup. Do they get automatically built when putting together the partial classes? Is there an option at that page/project level to instruct .NET to do this for you? Is this a difference between web app and web site?
This is a a .NET 3.5 site, C#, and it is running in a production environment.
Thanks in advance
You are correct in the difference is that she's running a Web Site project as opposed to a Web Application project. In a website there are no designer files. So to answer each of your questions...
Do they get automatically built when putting together the partial classes?
Yes, when the .aspx gets compiled the controls are created as if they were there...this happens in the background in VS so you get intellisense.
Is there an option at that page/project level to instruct .NET to do this for you?
Kinda, use a Web Application project for this :)
Is this a difference between web app and web site?
Yes, one of the main differences :) Web Application projects have a Page.aspx.designer.cs that house the control declarations.
I need to get existing web pages into an existing ASP.NET web site project in Visual Studio 2008. I simply tried to drag and drop the whole file folder content into the Visual Studio Solution Explorer or even to copy them into the web site folder.
Both ways, Visual Studio seems unable to map the .designer.cs files to the corresponding .aspx (or .master) file, even after restarting the whole IDE. The Solution Explorer entry looks in a way like this:
- Main.aspx
Main.aspx.cs
Main.aspx.designer.cs
Can I make Visual Studio file the designer-file below the aspx-file in any way? I strongly hope there is a simpler way than manually creating each file and copying and pasting the contents into each file by hand.
It sounds like you are trying to bring web application files into a web site. IIf that is the case, The designer files are not even needed. Just dont include them. They are generated and compiled in at runtime when the website runs.
Kind of partially self-answering my question:
In a web project - in contrast to a web site - it works perfectly through drag and drop onto the solution explorer, as I did for the web site before. To make the decision which type of "web site unit" to use there is another thread here on stackoverflow: ASP.NET Web Site or Web Project.
In a web site I can't even use YonahW's solution, because I can't just put files into the proper web site directory without causing them to be added to the web site automatically. Thanks to you anyway, YonahW. :-)
try copying the files through the filesystem and then right clicking on the project and selecting to add an existing item at which point you can choose all at once and this usually puts them in the proper places.
I need to combine a VB web project and a C# web project and have them run alongside each other in the same web root. For instance, I need to be able to navigate to localhost:1234/vbProjPage.aspx and then redirect to localhost:1234/cSharpProjPage.aspx. Is this possible from within Visual Studio 2008?
I know you have the ability to create a web site and throw everything into the root, but it would be best in this scenario to keep each project separate from each other.
UPDATE: To answer Wes' question, it is possible but not desirable to change paths like that (/vb/vbPage.aspx & /cs/csPage.aspx)
UPDATE: Travis suggested using sub-web projects. This link explains how to do it but the solution involves putting a project inside of a project, that is exactly what I am trying to avoid. I need the projects physically separated.
You can do this using sub-web projects. This has been available in Visual Studio since 2005 and works with the Web Application Project style of web site. ScottGu has a great blog entry describing the process. You may face some interesting challenges getting pages to commingle in the same folder, but the sub-web project structure should still lend you some ideas.
I don't think you'll be able to have two seperate projects but intermixing them within one project isn't a problem. You could always organize the files into folder to keep things seperate if you felt the need.
Just out of curiosity, would changing your url paths be out of the question? Instead of 1234/vbpage and 1234/cspage how about something like 1234/vb/page and 1234/cs/page ? I know you said same web root, but I'm just curious :)
you could use URL re-writting with a filter to look for "cs" or "vb" at the begining of each file and direct it to the appropriate directory.