Wednesday, May 11, 2011

How to Disable the ASP.NET v4.0 Extensionless URL feature on IIS 6.0

You can disable the v4.0 ASP.NET extensionless URL feature on IIS6 by setting a DWORD at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ASP.NET\4.0.30319.0\EnableExtensionlessUrls = 0. After changing the value, you will need to restart IIS in order for us to pick up the change, because it is only read once when IIS starts.

Note that for Wow64 (i.e., 32-bit worker process running on 64-bit OS), this registry key must be set at HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\ASP.NET\4.0.30319.0\EnableExtensionlessUrls.

Please refere to this URL for details: https://blogs.msdn.com/b/tmarq/archive/2010/06/18/how-to-disable-the-asp-net-v4-0-extensionless-url-feature-on-iis-6-0.aspx

Friday, April 29, 2011

The way to get control ID from custom Text source of RadSpell

Here is the way to get the TextBox ID from the custom text source of RadSpell.

this.sources[i].get_element().id

Monday, March 14, 2011

Save the scroll position when doing Ajax

var scrollTop;
Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequestHandler);
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);

function BeginRequestHandler(sender, args)
{
var elem = document.getElementById('<%= scrollBar.ClientID %>');
scrollTop=elem.scrollTop;
}

function EndRequestHandler(sender, args)
{
var elem = document.getElementById('<%= scrollBar.ClientID %>');
elem.scrollTop = scrollTop;
}

Wednesday, November 17, 2010

ASP.NET with SQL 2005 Cache Dependence

1) Check to see Service Broker is enabled

SELECT name, is_broker_enabled FROM sys.databases

2) To enable the Service Broker on your database

ALTER DATABASE Pubs SET ENABLE_BROKER
GO

3) Inform SQL Server that the user running IIS has permission to subscribe to query notificatoins.

GRANT SUBSCRIBE QUERY NOTIFICATIONS TO "IIS_SERVER\ASPNET"

4) Create a connectionStrings in the web.config

<connectionstrings>
<add name="myDbConnectionString" connectionstring="Data Source=localhost;Initial Catalog=MyDB;Integrated Security=True" providername="System.Data.SqlClient">
</connectionstrings>

5) Enable the website to be able to receive notifications.

protected void Application_Start(object sender, EventArgs e)
{
SqlDependency.Start(ConfigurationManager.ConnectionStrings["myDbConnectionString"].ConnectionString);
}

The following code also stops the listener:

protected void Application_End(object sender, EventArgs e)
{
SqlDependency.Stop(ConfigurationManager.ConnectionStrings["myDbConnectionString"].ConnectionString);
}

6) Sets up the cach dependency. Example code.

string tableName = query.Context.Mapping.GetTable(typeof(T)).TableName;
List result = HttpContext.Current.Cache[tableName] as List;

if (result == null)
{
using (SqlConnection cn = new SqlConnection(query.Context.Connection.ConnectionString))
{
cn.Open();
SqlCommand cmd = new SqlCommand(query.Context.GetCommand(query).CommandText, cn);
cmd.Notification = null;
cmd.NotificationAutoEnlist = true;
SqlCacheDependencyAdmin.EnableNotifications(query.Context.Connection.ConnectionString);
if (!SqlCacheDependencyAdmin.GetTablesEnabledForNotifications(query.Context.Connection.ConnectionString).Contains(tableName))
{
SqlCacheDependencyAdmin.EnableTableForNotifications(query.Context.Connection.ConnectionString, tableName);
}

SqlCacheDependency dependency = new SqlCacheDependency(cmd);
cmd.ExecuteNonQuery();

result = query.ToList();
HttpContext.Current.Cache.Insert(tableName, result, dependency);
}
}

Friday, November 5, 2010

Re-Associate the dbo to sa login after db restored

You could use the following SQL script to relink the dbo user of a db to login.

ALTER AUTHORIZATION ON DATABASE::[db name] TO [login name]

Wednesday, October 27, 2010

Tuesday, October 26, 2010

Required components of IIS7.0 for installing SQL Server 2005 on Windows 7

When you try to install SQL Server 2005 on Window 7, you may receive the following warning message for the IIS Feature Requirement item on the System Configuration Check page in the SQL Server 2005 Setup program:

Microsoft Internet Information Services (IIS) is either not installed or is disabled. IIS is required by some SQL Server features. Without IIS, some SQL Server features will not be available for installation. To install all SQL Server features, install IIS from Add or Remove Programs in Control Panel or enable the IIS service through the Control Panel if it is already installed, and then run SQL Server Setup again. For a list of features that depend on IIS, see Features Supported by Editions of SQL Server in Books Online.

This problem occurs because not all the IIS 7.0 components that SQL Server depends on are installed on the computer. The following table lists the affected components.

Component
Folder
Static ContentCommon HTTP Features
Default DocumentCommon HTTP Features
HTTP RedirectionCommon HTTP Features
Directory BrowsingCommon HTTP Features
ASP.NetApplication Development
ISAPI ExtensionApplication Development
ISAPI FiltersApplication Development
Windows AuthenticationSecurity
IIS MetabaseManagement Tools
IIS 6 WMIManagement Tools