Then in the same project’s content page’s code behind, we can use “this.Master” which is typed correctly to Site1 class (Site1.master’ class).

Then for any sub projects, all we need to do is to add project reference to the root project, add the MasterType line in the content page, and referring to the root project’s site1.master page as:

Master as RootProject.Site1

Hope this helps any one who have the similar questions.

Thanks

Xinyang Qiu

Web Platform and Tools Team

]]>https://blogs.msdn.microsoft.com/webdevelopertips/2011/09/19/tip-110-did-you-know-how-to-referencing-root-projects-master-pages-properties-from-sub-projects-content-page/feed/0Tip #109 Did you know … How to speed up build time by *only* building the currently selected project in a multi-project solution?https://blogs.msdn.microsoft.com/webdevelopertips/2011/08/15/tip-109-did-you-know-how-to-speed-up-build-time-by-only-building-the-currently-selected-project-in-a-multi-project-solution/
https://blogs.msdn.microsoft.com/webdevelopertips/2011/08/15/tip-109-did-you-know-how-to-speed-up-build-time-by-only-building-the-currently-selected-project-in-a-multi-project-solution/#respondMon, 15 Aug 2011 16:42:27 +0000https://blogs.msdn.microsoft.com/webdevelopertips/2011/08/15/tip-109-did-you-know-how-to-speed-up-build-time-by-only-building-the-currently-selected-project-in-a-multi-project-solution/When working with a solution that contains numerous projects, I find myself often wanting to only build and run the currently selected project. Other projects in the solution might have build errors that I don’t want to resolve at the current time. By default though, trying to do a CTRL+F5 on the currently selected project will cause Visual Studio (VS) to build all of the projects in a solution.

Let’s walk through how to tweak this behavior.

We’ll start with a solution that has two projects – WebApplication_1 and WebApplication_2.

First, we’ll configure VS to set the “Startup Project” as the “Current selection” in the “Solution Explorer” window. You can configure this via the Properties settings of a solution file (right click on it) and then setting the “Startup Project” to “Current selection”. Now, the project highlighted in the “Solution Explorer” is the one that’s run by default.

Let’s run WebApplication_1 by selecting it in Solution Explorer.

Next, we’ll do a CTRL+F5. The VS output window shows:

Notice that we’ve built two projects yet I only wanted to run one of them and there’s no dependency configured between the two. Visual Studio by default builds all of the projects in a solution. You can imagine the delay you might incur if you had a solution with numerous projects and if some of these included pre- or post-build tasks.

Thankfully, there’s a way to change this.

Under “Tools –> Options”, “Projects and Solutions” (might need to check “Show all settings”), there’s a setting called “Only build startup projects and dependencies on Run”. Check that box.

Now, if we return to our solution and repeat trying to run just WebApplication_1, we see that VS only builds that project and not the other one as well.

]]>https://blogs.msdn.microsoft.com/webdevelopertips/2011/08/15/tip-109-did-you-know-how-to-speed-up-build-time-by-only-building-the-currently-selected-project-in-a-multi-project-solution/feed/0Tip #108 Did you know … How to improve reference efficiency in JavaScript files inside a web project?https://blogs.msdn.microsoft.com/webdevelopertips/2011/03/31/tip-108-did-you-know-how-to-improve-reference-efficiency-in-javascript-files-inside-a-web-project/
https://blogs.msdn.microsoft.com/webdevelopertips/2011/03/31/tip-108-did-you-know-how-to-improve-reference-efficiency-in-javascript-files-inside-a-web-project/#respondThu, 31 Mar 2011 10:06:26 +0000https://blogs.msdn.microsoft.com/webdevelopertips/2011/03/31/tip-108-did-you-know-how-to-improve-reference-efficiency-in-javascript-files-inside-a-web-project/In Visual Studio 2010, we can reference other JavaScript files inside current JavaScript file like the following, to get the IntelliSense.

/// <reference path="JScript2.js" />

What if you have many JavaScript files and you’ve to reference many project wide JavaScript files inside each file? You can put the following block in each of the JavaScript files that need the reference like following:

But this won’t be efficient especially some referencing file name is going to change, such as when JQuery library version changes. The trick is to create a project wide reference JavaScript file, and explicitly reference this file from other JavaScript files. For example, we can create a file called reference.js which contains the above code. Then for other JavaScript files, we can reference it by dragging and drop the reference.js file into the JavaScript editor, which will generate the following:

/// <reference path="Scripts/reference.js" />

Basically, Visual Studio 2010 recursively check the references included in the referenced JavaScript files to find the current JavaScript file’s references. I hope this can ease some pain in the development.

Best Regards

Xinyang Qiu

Web Platform And Tools

]]>https://blogs.msdn.microsoft.com/webdevelopertips/2011/03/31/tip-108-did-you-know-how-to-improve-reference-efficiency-in-javascript-files-inside-a-web-project/feed/0Tip #107 Did you know … How to improve debugging performance for MVC2 application in Visual Studio 2010 Ultimate?https://blogs.msdn.microsoft.com/webdevelopertips/2010/08/19/tip-107-did-you-know-how-to-improve-debugging-performance-for-mvc2-application-in-visual-studio-2010-ultimate/
https://blogs.msdn.microsoft.com/webdevelopertips/2010/08/19/tip-107-did-you-know-how-to-improve-debugging-performance-for-mvc2-application-in-visual-studio-2010-ultimate/#commentsThu, 19 Aug 2010 11:40:58 +0000https://blogs.msdn.microsoft.com/webdevelopertips/2010/08/19/tip-107-did-you-know-how-to-improve-debugging-performance-for-mvc2-application-in-visual-studio-2010-ultimate/VS2010 Ultimate included IntelliTrace functionality by default. IntelliTrace captures events (e.g. exceptions), and can affect performance of debugging. The typical performance hit is about 5% in the default mode (collection can be increased to collect method calls and parameters which can have up to a 15x hit). However this is completely dependent on what events and how many are occurring.

MVC 2.0 development is such an example. Because System.Web.dll v2.0 (the core component of ASP.NET up to .NET 3.5) has some inefficient APIs for instantiating objects from virtual paths, MVC 2.0 mitigates this problem by having a cache of view lookups. By default this cache is disabled during development so that the changes you make are immediately visible, which is why it throws many exceptions during debug time. On a real production server these exceptions would not occur after the lookups are cached. Thus launching an MVC 2.0 app with IntelliTrace enabled runs significantly slower because a call stack is captured for every exception. As a side note, MVC 3 will be using new APIs added in .NET 4 so this should not be a problem anymore.

IntellliTrace is however not the debugger, and can be turned off (Tools -> Options -> Intellitrace) if this is causing too much of a problem.

From my own machine, I downloaded MVC 2 application Orchard source 0.5.144.zip from http://orchard.codeplex.com/, and setup it using the compact database after running it. When I do F5 with IntelliTrace on by default, the start up process took about 14 seconds. When I do F5 with IntelliTrace disabled, the start up process took about 9 to 10 seconds.

Hope this helps you to debug faster if you don’t need IntelliTrace when debugging your MVC2 application.

- Xinyang Qiu | Web Platform and Tools Team

(Note, I’ve added the underlining reason of MVC 2.0 debugging behavior of throwing exceptions on 9/10/2010, with help from colleague Marcin Dobosz )

]]>https://blogs.msdn.microsoft.com/webdevelopertips/2010/08/19/tip-107-did-you-know-how-to-improve-debugging-performance-for-mvc2-application-in-visual-studio-2010-ultimate/feed/3Tip #106 Did you know … How to solve the errors when aspnetdb.mdf is created dynamically with IIS?https://blogs.msdn.microsoft.com/webdevelopertips/2010/05/06/tip-106-did-you-know-how-to-solve-the-errors-when-aspnetdb-mdf-is-created-dynamically-with-iis/
https://blogs.msdn.microsoft.com/webdevelopertips/2010/05/06/tip-106-did-you-know-how-to-solve-the-errors-when-aspnetdb-mdf-is-created-dynamically-with-iis/#commentsThu, 06 May 2010 19:14:09 +0000https://blogs.msdn.microsoft.com/webdevelopertips/2010/05/06/tip-106-did-you-know-how-to-solve-the-errors-when-aspnetdb-mdf-is-created-dynamically-with-iis/In VS2010 all editions, the default .NET Framework 4.0 ASP.NET Web Site and Web Application template create default website with following connection string in the web.config:

To get the aspnetdb.mdf created on the fly, one can simply Ctrl-F5 to run the web site or web application. Enter a username and password and click “Log In” button to let the ASP.NET Development Server or IIS server process create the aspnetdb.mdf file for you.

Problem #1

If you created the website as a http web, such as http://localhost/test1/ , or you created the web application and make it use local IIS web server, you may encounter the following error message on win7 and win2008 R2 when trying to let IIS server process create the aspnetdb.mdf file dynamically:

Server Error in '/test1' Application.

Failed to generate a user instance of SQL Server due to failure in retrieving the user's local application data path. Please make sure the user has a local user profile on the computer. The connection will be closed.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

SQLExpress database file auto-creation error:

The connection string specifies a local Sql Server Express instance using a database location within the application's App_Data directory. The provider attempted to automatically create the application services database because the provider determined that the database does not exist. The following configuration requirements are necessary to successfully check for existence of the application services database and automatically create the application services database:

If the application is running on either Windows 7 or Windows Server 2008R2, special configuration steps are necessary to enable automatic creation of the provider database. Additional information is available at: http://go.microsoft.com/fwlink/?LinkId=160102 . If the application's App_Data directory does not already exist, the web server account must have read and write access to the application's directory. This is necessary because the web server account will automatically create the App_Data directory if it does not already exist.

If the application's App_Data directory already exists, the web server account only requires read and write access to the application's App_Data directory. This is necessary because the web server account will attempt to verify that the Sql Server Express database already exists within the application's App_Data directory. Revoking read access on the App_Data directory from the web server account will prevent the provider from correctly determining if the Sql Server Express database already exists. This will cause an error when the provider attempts to create a duplicate of an already existing database. Write access is required because the web server account's credentials are used when creating the new database.

Sql Server Express must be installed on the machine.

The process identity for the web server account must have a local user profile. See the readme document for details on how to create a local user profile for both machine and domain accounts.

The above error is most likely due to IIS7 ASP.NET v4.0 application pool is running under ApplicationPoolIdentity. Change it to NetworkService will solve the issue. Details is in http://go.microsoft.com/fwlink/?LinkId=160102 . The following picture shows how to do it in IIS Manager:

Problem #2

If created web application is in default user project directory, you may also get the following error message: (Note, aspnetdb.mdf is created under app_data folder successfully, but just cannot get access to it)

Server Error in '/WebApplication1' Application.

An attempt to attach an auto-named database for file D:\Users\FWTLABA\Documents\Visual Studio 2010\Projects\test1\WebApplication1\App_Data\aspnetdb.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: An attempt to attach an auto-named database for file D:\Users\FWTLABA\Documents\Visual Studio 2010\Projects\test1\WebApplication1\App_Data\aspnetdb.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

This problem and workaround is explained in detail in http://support.microsoft.com/?kbid=2002980 . It’s a SQL express limitation if the project is under the default project location, such as c:\users\[ACCOUNTNAME]\Documents\Visual Studio 20XX . If this is a personal computer, it might be a better idea to create the web application project in a non-default folder to avoid the workaround steps.

Also, VS2005, VS2008, VS2010 all supports the following ways to create aspnetdb database:

]]>https://blogs.msdn.microsoft.com/webdevelopertips/2010/05/06/tip-106-did-you-know-how-to-solve-the-errors-when-aspnetdb-mdf-is-created-dynamically-with-iis/feed/4Tip #105: Did you know … How to include empty directory when package a web application?https://blogs.msdn.microsoft.com/webdevelopertips/2010/04/29/tip-105-did-you-know-how-to-include-empty-directory-when-package-a-web-application/
https://blogs.msdn.microsoft.com/webdevelopertips/2010/04/29/tip-105-did-you-know-how-to-include-empty-directory-when-package-a-web-application/#commentsThu, 29 Apr 2010 15:06:45 +0000https://blogs.msdn.microsoft.com/webdevelopertips/2010/04/29/tip-105-did-you-know-how-to-include-empty-directory-when-package-a-web-application/By design, Visual Studio 2010 will skip the empty directory when packaging web application project using web deploy. To get empty directory packaged and deployed, we can work around this by adding an empty stub file inside the directory to make it non-empty. Then web deploy will package and deploy the directory with the stub file.

]]>https://blogs.msdn.microsoft.com/webdevelopertips/2010/04/29/tip-105-did-you-know-how-to-include-empty-directory-when-package-a-web-application/feed/6Tip #104: Did you know … How to view text for the ‘hint’ buttons on the Publish Web Dialog?https://blogs.msdn.microsoft.com/webdevelopertips/2010/04/26/tip-104-did-you-know-how-to-view-text-for-the-hint-buttons-on-the-publish-web-dialog/
https://blogs.msdn.microsoft.com/webdevelopertips/2010/04/26/tip-104-did-you-know-how-to-view-text-for-the-hint-buttons-on-the-publish-web-dialog/#commentsMon, 26 Apr 2010 13:00:00 +0000https://blogs.msdn.microsoft.com/webdevelopertips/2010/04/26/tip-104-did-you-know-how-to-view-text-for-the-hint-buttons-on-the-publish-web-dialog/

After the Beta 2 release of Visual Studio 2010, the Publish Web Dialog was modified to include two information buttons associated with the Service URL and Site/application text boxes. (See Figure 1)

There are two keys to remember when trying to view the ‘help’ text associated with these buttons:

Patience

Hover – don’t click

In order to reveal the valuable information that these help icons can unlock, simply move your mouse to hover over them and then be patient for a second (i.e. quite moving your mouse around and don’t click them). Presto, the help text will then appear. (See Figure 2 and Figure 3)

]]>https://blogs.msdn.microsoft.com/webdevelopertips/2010/04/26/tip-104-did-you-know-how-to-view-text-for-the-hint-buttons-on-the-publish-web-dialog/feed/2Tip #103 revisitedhttps://blogs.msdn.microsoft.com/webdevelopertips/2010/04/23/tip-103-revisited/
https://blogs.msdn.microsoft.com/webdevelopertips/2010/04/23/tip-103-revisited/#commentsFri, 23 Apr 2010 10:08:52 +0000https://blogs.msdn.microsoft.com/webdevelopertips/2010/04/23/tip-103-revisited/In Tip #103 I showed a way of customizing the start page in order to add the New Website and Open Website controls. It turns out that using a loose XAML file as I did in that post is not the recommended practice; in fact, it’s recommended that you don’t do it that way.

The recommended practice is to create a Visual Studio extension, using the Custom Start Page template available from the Visual Studio gallery.

Using the new template, I have reproduced the start page with a VSIX package. This will install on Visual Studio 2010 (Pro, Premium, Ultimate) and on Visual Web Developer 2010 Express. To give it a go, try the new package here, with sources here

]]>https://blogs.msdn.microsoft.com/webdevelopertips/2010/04/23/tip-103-revisited/feed/1Tip #103: Adding the New Website and Open Website buttons to the VS2010 Start Pagehttps://blogs.msdn.microsoft.com/webdevelopertips/2010/04/14/tip-103-adding-the-new-website-and-open-website-buttons-to-the-vs2010-start-page/
https://blogs.msdn.microsoft.com/webdevelopertips/2010/04/14/tip-103-adding-the-new-website-and-open-website-buttons-to-the-vs2010-start-page/#commentsWed, 14 Apr 2010 09:45:12 +0000https://blogs.msdn.microsoft.com/webdevelopertips/2010/04/14/tip-103-adding-the-new-website-and-open-website-buttons-to-the-vs2010-start-page/In the new VS2010 UI, the start page has been completely re-written. Part of the changes made were to hide the New Website and Open Website buttons. Basically it went from the old look in VS2008:

To the new look in VS2010:

Of course, ASP.NET website projects are still around and not going away soon. Here’s a very quick way to make them show up on the Start Page again.

Open Visual Studio 2010 and open Tools –> Options. Find the option under Environment –> Startup, and set the Customize Start Page dropdown to point at the new XAML file.

That’s it! Now your start page will look like this:

Note: you may get a security warning that the file is not trusted. This is due to downloading it from the scary Internet. From Windows Explorer, you can right-click the file, select Properties, and then select the Unblock button by the bottom:

]]>https://blogs.msdn.microsoft.com/webdevelopertips/2010/04/14/tip-103-adding-the-new-website-and-open-website-buttons-to-the-vs2010-start-page/feed/3Tip#102: Did you know… How to specify tag specific formattinghttps://blogs.msdn.microsoft.com/webdevelopertips/2010/03/25/tip102-did-you-know-how-to-specify-tag-specific-formatting/
https://blogs.msdn.microsoft.com/webdevelopertips/2010/03/25/tip102-did-you-know-how-to-specify-tag-specific-formatting/#commentsThu, 25 Mar 2010 11:22:22 +0000https://blogs.msdn.microsoft.com/webdevelopertips/2010/03/25/tip102-did-you-know-how-to-specify-tag-specific-formatting/Let’s see this with an example. I have the following html code on my page.

I want the content inside td should remain on the same line after formatting the document.

Following steps would show how you can specify tag specific formatting for the Visual Studio editor

Right click on the editor in an aspx file and select Formatting and Validation... (or alternatively you can go from Menu Tools-> Options -> Text Editor -> HTML -> Formatting)

From the options dialog select 'Tag specific options'

On the tag specific dialog you can select a tag or create new one and select various formatting options. For this example, I selected Client HTML Tags –> td and then set Line breaks as none and click Ok.

Now if I format the document, there are no line breaks added to the content of the td.