Copied RSS Feed

ASP.NET MVC

ASP.NET MVC – Setup Debugging Framework Source Code

As you are aware, complete source code for the ASP.NET MVC Framework is available on CodePlex. If you have not already done so, please download the source from CodePlex. With the source and a little setup, you can debug right into the framework’s source. This is often very useful when troubleshooting pesky issues.

In order to setup debugging please follow the procedure below.

  1. Remove your project’s reference to system.web.mvc.
  2. Add the project System.Web.Mvc.csproj, available under MVCsrcSystemWebMvc (relative to the folder where you unzipped the source code), to your solution.
  3. Add a reference to the project you just added to your main ASP.NET MVC application project (as a project reference). This reference replaces your original system.web.mvc assembly reference.
  4. Uncomment the reference to System.Web.Mvc in your web.config file as shown below.

 

<compilation debug="true">

<assemblies>

<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

<add assembly="System.Web.Abstractions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

<add assembly="System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

<!--<add assembly="System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>-->

<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

<add assembly="System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

</assemblies>

</compilation>
  • Locate the web.config file available under the Views folder and replace all PublicKeyToken instances under the pages node with null (original value will be 31BF3856AD364E35) as shown below.
<pages

validateRequest="false"

pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"

pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"

userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">

<controls>

<add assembly="System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" namespace="System.Web.Mvc" tagPrefix="mvc" />

</controls>

</pages>

You should now be able to debug into the ASP.NET MVC source code. Please do remember to reverse these steps when deploying your project.

ASP.NET Futures Assembly

If you are using the ASP.NET futures assembly, you can add a reference to this assembly also and debug without any additional changes. The source code for the futures assembly is installed under MVCsrcMvcFutures along with the ASP.NET MVC source code.

Meet the Author

Daniel Jebaraj

Daniel Jebaraj is the CEO and one of the founders of Syncfusion®. Daniel's primary goal is to give Syncfusion® customers access to the widest set of world-class frameworks for all their software development needs and to affordable enterprise software that helps grow their businesses.