3D printing Aerodynamic engineering Aeronautical engineering Aeronautical engineering books Airports Architecture Artificial intelligence Automobiles Blast Resistant Design Books Bridges Building Codes Cabin Systems Civil Engineering Codes Concrete Conferences Construction Management Construction Materials Cooling Cryptocurrency Dams Do it Yourself Docks and Harbours Downloads Earthquake Engineering Electronics Engineering Engines Environmental Design & Construction Environmental Engineering Estimation Fluid Mechanics Fluid Mechanics Books Formwork design foundation engineering General Geotech Books Geotechnical Engineering Global Positioning System HVAC Hydraulics Hydraulics Books Hydro Power Hydrology Irrigation Engineering Machinery Magazines Management Books Masonry Mechanical Engineering Mechanics Mechanics Books Miscellaneous Books Modern Steel Construction Nanotechnology Natural Hazards Network Security Engineer Networking Systems News Noise and Attenuation Nuclear Engineering Nuclear Hazards to Buildings Pavement Design Prestressed Concrete Project Management Project Management Books Quantity Survey Quantity Survey Books railways RCC Structural Designing Remote Sensing Remote Sensing and GIS Books Renewable Energy Reports Resume Roads scholarships Smart devices Software Software Engineering Soil Mechanics Solar Energy Special Concrete Spreadsheets Steel Steel Spreadsheets Structural Analyses structures Structures Books Surveying Surveying Books Testing Thermodynamics Thesis Transportation Books Transportation Engineering Tunnel Engineering Wind Energy Zero Energy Buildings

Sharing Master Pages in Visual Studio

After you have created a set of master pages, you might want to make them available to others, such as other developers creating Web applications in your company. In most cases, you probably do not want other developers to change the master pages. There are several ways you can make your master pages available for reuse.
The simplest solution is to copy the master pages to a file directory that other projects can then reference. Developers could navigate to the directory that contains the master pages and then add them to a Web application project. If you want to control who can modify the master pages, you can set security permissions on the directory that contains the master pages. The additional solutions outlined below allow greater flexibility in where you store the master pages intended for reuse.

Use Virtual Directories

Another solution would be to store the master pages in a virtual directory. Virtual directories are a convenient way to set up a site for local Web development work because they do not require a unique site identity. This means that a virtual directory requires fewer steps than it would to create a unique site to store your master pages. Virtual directories are maps to the physical location of files that a Web application can use. The files do not have to be under the root of the Web application. This approach enables you to maintain one set of master pages in one location that various Web applications residing on remote machines can use.
To use master pages in a virtual directory, a developer would navigate to the directory and add the master pages to the current Web application project. For more information about virtual directories, see How to: Create IIS Virtual Directories in Visual Studio or How to: Create and Configure Virtual Directories in IIS 5.0 and 6.0.

Use Virtual Paths

You can use virtual paths to provide content from locations other than the file system. If, for example, you store your master pages in a Microsoft SQL Server database, you can create a virtual path provider to dynamically retrieve content from the database. You can also use virtual paths to provide content from a compressed .zip file.
To create a virtual path provider that can be used to provide content and files for compilation in another ASP.NET version 2.0 Web application, the developer must:
  •       Create a VirtualPathProvider class and implement all the required methods to handle the master page file requests.
  •      Register the virtual path provider to let the ASP.NET hosting environment know where the master pages are located.
  •     Create VirtualFile and VirtualDirectory objects to stream the content.
For more information on creating a virtual path provider or using virtual paths to provide content, see article 910441, "How to use virtual path providers to dynamically load and compile content from virtual paths in ASP.NET 2.0" in the Microsoft Knowledge Base and Virtualizing Access to Content: Serving Your Web Site from a ZIP File.

Precompile the Code Used in a Master Page

If you are concerned about code in your master pages being visible to others reusing the pages, you can precompile the master pages' code into a library. In this library, you can include code-behind pages as well as user or custom controls. Compiling master pages does not remove the declarative code for the master files or any server controls used, but you can compile the master files to remove the code for controls or code-behind pages used by the master pages.
If you choose to compile the master pages into a library, you must use the "updatable" build option that allows for later modification of the markup. This option is determined by the Allow the precompiled site to be updatable check box in the Publish Web Site dialog box. For more information about precompiling pages into a library that can be reused, see Building Re-Usable ASP.NET User Control and Page Libraries with VS 2005.

Author Name


Contact Form


Email *

Message *

Powered by Blogger.