How to: Generate Dependency Graphs for ASP.NET Web Projects

This Visual Studio 2010 feature pack lets you explore the organization and relationships for ASP.NET Web projects in Visual Studio 2010 Ultimate by generating dependency graphs. For more information, see Visual Studio Feature Packs.

Important

You must install a Visual Studio 2010 Feature Pack to use this feature.

You can generate dependency graphs for the following Web project types:

  • ASP.NET Web sites

  • ASP.NET Web applications

  • ASP.NET MVC 2 projects

A dependency graph represents elements and their relationships as nodes that are connected by links.

Graph for Web project and all dependencies

Dependency graph for an ASP.NET Web project and all code dependencies

Use these graphs to help you visualize, explore, and manage the logical organization and dependencies between Web artifacts, such as master pages, controls, server controls, models, views, controllers, and code-behind elements. This will help you understand how changes to an artifact might affect other related artifacts. You can generate a dependency graph for all Web sites in the solution or for specific project items.

Note

Only Web projects will appear on the graph. If you have a very large solution, generating a dependency graph might take some time to parse all the files or cause an out of memory exception. If this occurs, reduce the scope of your solution or use Architecture Explorer to select specific elements and relationships before you generate the graph. If you open a saved Web project dependency graph in Visual Studio Ultimate that does not have the feature pack installed, then icons on the graph will not appear correctly.

Remember the following items when you generate graphs for Web projects:

  • The graph shows only dependencies that are relevant to the Web projects.

  • A warning icon (!) on a node indicates that a parsing issue has occurred. To see more details about the issue, move the pointer on top of the node to read the tooltip.

  • Links between Web site artifacts represent dependencies such as the use of one artifact by another. Links between code elements represent dependencies such as method calls.

  • For ASP.NET MVC 2 projects, Visual Studio displays nodes and links for artifacts only if they have the expected file names and are in their expected folder locations.

  • The following action has no effect: Move the pointer on top of a link, and then double-click the plus sign (+) to view more details about the link.

  • When generating the graph, Visual Studio might not be able to resolve the namespaces of certain types. These types will appear in the Global namespace on the graph. You will not be able to explore these types further by double-clicking them on the graph.

  • Nodes on the graph might represent types in projects that are not built. Double-clicking these nodes to view the code might fail or take a few seconds. Performing this step repeatedly might create delays and cause the graph to become unresponsive. To avoid or fix this issue, make sure that you build the solution, and then generate the graph.

  • Custom controls that have different namespaces but are registered with the same tagprefix will appear in the same namespace on the graph. For more information, see @ Register.

  • For ASP.NET MVC 2 projects, links that represent calls to the following methods might not appear on the graph, for example, if their arguments cannot be parsed:

    • System.Web.Mvc.Html.RenderPartialExtensions.RenderPartial

    • System.Web.Mvc.Html.ChildActionExtensions.Action

    • System.Web.Mvc.Html.ChildActionExtensions.RenderAction

    For more information, see:

For more information about ASP.NET Web projects, see ASP.NET 4.

In This Topic

  • See dependencies for Web projects in a solution

  • See dependencies for specific Web project items

  • See deeper levels of dependencies on an existing graph

See Dependencies for ASP.NET Web Projects in a Solution

You can generate a graph that shows the dependencies and logical organization of Web projects at the following levels:

  • All Web projects in the solution and code dependencies at the class level only

  • All Web projects and code dependencies at all levels

Graph for Web project and class-level dependencies

Dependency graph for an ASP.NET Web project and class-level dependencies only

Graph for Web project and all dependencies

Dependency graph for an ASP.NET Web project and all code dependencies

  1. Open a solution that contains at least one ASP.NET Web project.

  2. On the Architecture menu, point to Generate Dependency Graph, and then follow one of these steps:

    To

    Click

    See dependencies for all Web projects and code dependencies at the class level only

    By Web Site

    To add method dependencies to an existing graph, right-click the graph, and then click Get Code Dependencies.

    See dependencies for all Web projects and code dependencies at all levels

    By Web Site with Code Dependencies

  3. To view the source of an artifact, double-click its node on the graph.

    For more information about how to rearrange and edit the graph, see:

See Dependencies for Specific Web Project Items

Use Architecture Explorer to select specific items and relationships in Web projects. You can then create a dependency graph from selected items.

Note

This functionality supports only ASP.NET Web application projects and ASP.NET MVC 2 projects.

  1. Open a solution that contains at least one Web project.

  2. If Architecture Explorer is not open, on the Architecture menu, point to Windows, and then click Architecture Explorer.

  3. Use Architecture Explorer to find the artifacts and relationships that you want to visualize.

  4. Select the items and drag them to a blank graph or to an existing graph.

For more general information about how to use Architecture Explorer to browse code elements and solution artifacts, see:

See Deeper Dependencies on an Existing Graph

If you generated a graph for Web projects that shows only class-level dependencies, you can add method-level dependencies without generating a new graph.

Warning

This action removes any items that were manually added to the graph and have no relationships with the Web sites on the graph.

To see deeper dependencies on an existing graph

  • Right-click the graph, and then click Get Code Dependencies.

See Also

Concepts

How to: Browse and Navigate Graph Documents

How to: Explore Code with Dependency Graphs

How to: Edit and Customize Graph Documents

How to: Generate Dependency Graphs for C and C++ Code

Visualizing Existing Code

Other Resources

ASP.NET 4