SteGriff

Blog

Next & Previous

Compiling a decompiled ASP.Net MVC website

We recently took delivery of a codebase with no code… well, it might actually turn out that the original developer comes through but I started this process anyway! Currently the binaries on the FTP server are the only resource available.

Set up the environment

Flatten the main project

At this point, the project folder needs to be flattened so that the csproj is in the same directory as all the website files.

You can copy the ProjectTypeGuids from another website project, or you might be able to use these:

<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>

Add IIS stuff to the bottom of web.config, copied from another website project (change the FlavorProperties GUID to a new randomly generated GUID):

<ProjectExtensions>
	<VisualStudio>
	  <FlavorProperties GUID="{d597882c-d741-470d-bba0-d7bd6ca0568a}">
		<WebProjectProperties>
		  <UseIIS>True</UseIIS>
		  <AutoAssignPort>True</AutoAssignPort>
		  <DevelopmentServerPort>0</DevelopmentServerPort>
		  <DevelopmentServerVPath>/</DevelopmentServerVPath>
		  <IISUrl>http://localhost:57441/</IISUrl>
		  <NTLMAuthentication>False</NTLMAuthentication>
		  <UseCustomServer>False</UseCustomServer>
		  <CustomServerUrl>
		  </CustomServerUrl>
		  <SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
		</WebProjectProperties>
	  </FlavorProperties>
	</VisualStudio>
</ProjectExtensions>

Decompile references

Now I went back to navigating the project tree in JustDecompile to discover any other projects I needed

Create a solution

Try it

You’re roughly ready to start building and testing it. Visual Studio should present the correct browser-play button in the debug toolbar. If it doesn’t, the website csproj is still set up wrong (see the code snippets above). Maybe restart Visual Studio?

You will probably get errors the first time you start the site, you’ll have to triage and fix them with liberal use of DuckDuckGo.

Fix global.asax

This might not happen to you, but my website, when launched, complained that it couldn’t locate the MyWebsite.MvcApplication class, which had been written to overload HttpApplication. The problem was due to the project output path being bin/Debug instead of just bin.