Jack @ ASP.NET

As a software engineer, I focus on .NET, especially asp.net, C#, WCF and so on, and I am also very interested in Search Engine Optimization.

Entries Tagged ‘Windows’

Setting an aspnet.config File per Application Pool

The aspnet.config file is a little known config file which is supported by ASP.NET 2.0 and greater.  Generally it lives in the root of the framework folder, for example:

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config
C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet.config
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\aspnet.config
C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet.config

This config file is further leveraged in ASP.NET 4.0 for concurrency and threading.  For example, you can set maxConcurrentRequestsPerCPU, maxConcurrentThreadsPerCPU and requestQueueLimit, in addition to the previous runtime settings.

In Windows Server 2008 R2 (IIS 7.5) support was added to allow different settings per application pool.  Where previously the settings had to be applied to the whole framework version, now they can be specific to each app pool.  It does this by allowing you to create a custom aspnet.config file per app pool.  You can save them wherever you want on disk and IIS will pick them up when the app pool starts.

Note that the framework aspnet.config file is still used so only differences per app pool need to be set here.

Here’s an example of what the file can contain:

<?xml version="1.0" encoding="UTF-8" ?>

<configuration>

    <runtime>

        <legacyUnhandledExceptionPolicy enabled="false" />

        <legacyImpersonationPolicy enabled="true"/>

        <alwaysFlowImpersonationPolicy enabled="false"/>

        <SymbolReadingPolicy enabled="1" />

        <shadowCopyVerifyByTimestamp enabled="true"/>

    </runtime>

    <startup useLegacyV2RuntimeActivationPolicy="true" />

  <system.web>

    <applicationPool

        maxConcurrentRequestsPerCPU="5000"

        maxConcurrentThreadsPerCPU="0"

        requestQueueLimit="5000" />

  </system.web>

</configuration>

Visual Studio 2010 crash when creating a New Project

My visual studio 2010 crashed when creating a New Project. My environment is Windows 7 – 64 bit, Visual Studio 2010. And after google the solution, if got the solution

Delete or move the contents of C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ProjectTemplatesCache

Hope it may help the one also met this problem

Top 5 of my favorite free Windows Live Writer (WLW) plugin

I like free one, so I only list top 5 of my favorite ones.

  1. Twitter Update: (by Krishnan)
  2. Allow you to add up to 3 twitter accounts and tweet according to the blog you post.
    In the options page enter default Twitter account user name and password, which will be used when there is no matching twitter account for a blog is found.
    Add blog home page Urls in the text box (seperated by | if you have more than one) and enter the twitter account details of the corresponding twitter account

  3. Blog This for Firefox:Adds a button to Firefox which starts a new Windows Live Writer blog post prepopulated with content and title from the current web page. Blog the whole page, or just selected snippets. Interacts with other registered plugins to parse and structure web content where appropriate. Blog quickly when you find something of interest on the web.
  4. Syntax Higlighter for WLW: Add smart content editor syntax higlighter 2.0 support for Windows Live Writer.
  5. Facebook Live Writer Plugin: Prompts you to share a link on Facebook whenever you publish a new post.
  6. Tag Generator: A tool to automatically generate tags based on the content of your post. Supports Technorati, WordPress and Blogger

How to launch a process with admin rights from a Visual Studio 2008 add-in on Windows System with UAC.

While on Windows XP by default every user is an administrator (although you can create “standard” users) Windows Vista introduces a new feature named User Account Control (UAC) which causes that by default even administrators run as standard users. When a process requires administrator rights to run, the operating system prompts for an “elevation prompt”.

Here is a demo:

System.Diagnostics.Process process = null;
System.Diagnostics.ProcessStartInfo processStartInfo;

processStartInfo = new System.Diagnostics.ProcessStartInfo();

processStartInfo.FileName = "regedit.exe";

if (System.Environment.OSVersion.Version.Major >= 6)  // Windows Vista or higher
{
   processStartInfo.Verb = "runas";
}
else
{
   // No need to prompt to run as admin
}

processStartInfo.Arguments = "";
processStartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
processStartInfo.UseShellExecute = true;

try
{
   process = System.Diagnostics.Process.Start(processStartInfo);
}
catch (Exception ex)
{
   MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
   if (process != null)
   {
      process.Dispose();
   }
}

The terminal server has exceeded the maximum number of allowed connections

Terminal Server Error Message

When a user establishes a Remote Desktop connection to the WHS this connection will remain active until the user selects “Log Off” from the Start Menu. If a user simply closes the remote desktop window when they’re finished, that username will still remain logged on.

The software running on the WHS to facilitate the Remote Desktop connection will only allow for up to two simultaneous sessions. Active and disconnected sessions are calculated in this connection limit as is the Administrator account also. The console session, however, does not count against the connection limit.

If a third attempt is made to login to the server, the dreaded “The terminal server has exceeded the maximum number of allowed connections” error will be shown to the user, and they will be unable to complete the login process. You can’t even connect to disconnect the old sessions BUT there is a way around this:

Simply click OK to the error message and wait for unto 30 seconds for the window to close then simply type the following in a Start – RUN or CMD Prompt on your client machine.

mstsc /v:00.00.00.00 /f -console
Replace 00.00.00.00 with your server’s IP Address or server name. e.g.SERVER

Type in your administrator password. This will then connect you to the Console Session on the server and allow you to remote control the machine again.

Once in Click Start, point to All Programs, point to Administrative Tools, and then  click Terminal Services Manager.

In the left hand column you should see your server name. Click on it once. Note the Users Tab in the right pane.

You should see a list of users. You need to reset the two “Disconnected” users. You can do this by right clicking the disconnected user and selecting “Reset.” You should now be able to connect with RDP again after Start – Log Off.

When logging in under this special Console session always kill the inactive sessions first, because if you get disconnected again you will have to connect your monitor, keyboard and mouse.

Only use this session to terminate the other two sessions and not for any other use.

In future when you are done with a Remote Desktop session on WHS, you should always use “Log Off” rather than disconnecting by closing the RD window with the X as this will disconnect from the session but leave it active.