Archive

Archive for the ‘Asp.Net’ Category

SqlCacheDependency and CommandNotification Rule

August 23rd, 2007 No comments

Continuing with my study using AppDev.com course, I feel compelled to mention two crucial steps in setting up “Query Notification” when using database caching techniques. I spent almost two days trying to get this techique to work! Thanks to AppDev it works now.

After adding

<%@ OutputCache SqlDependency="CommandNotification" Duration="9999999" VaryByParam="None" %>

there are two things that we must get right for this setup to work:

1. Establishing the target table and writing a correct query, as outlined in this MSDN article.

2. Configuring Service Broker as listed below

USE YourDatabaseName;

– Ensure compatibility with SQL Server 2005
EXECUTE sp_dbcmptlevel ‘Northwind’,90;

– Enable Service Broker
IF NOT EXISTS (SELECT * FROM sys.databases
WHERE name = YourDatabaseName AND is_broker_enabled = 1)
BEGIN
ALTER DATABASE Northwind SET ENABLE_BROKER
WITH ROLLBACK AFTER 5 SECONDS;
– Set Trustworthy
ALTER DATABASE Northwind SET TRUSTWORTHY ON;
END;
GO

– Create an encryption key for Service Broker
IF NOT EXISTS
(SELECT * FROM sys.symmetric_keys
WHERE symmetric_key_id = 101)
CREATE MASTER KEY ENCRYPTION BY PASSWORD = N‘t0psecret’;
GO

– Create a Service Broker endpoint
CREATE ENDPOINT BrokerEndpoint
STATE = STARTED
AS TCP ( LISTENER_PORT = 4037 )
FOR SERVICE_BROKER ( AUTHENTICATION = WINDOWS );
GO

select * from sys.dm_qn_subscriptions

It’s easy when you know ;)

Categories: Asp.Net Tags:

ASP.NET Web Site Administration Tool on a Server

July 13th, 2007 1 comment

When developing Asp.Net application with Visual Studio 2005  I use Web Application Project. However, this type of project does not allow using Web Site Administration Tool, so I searched the web for a possible solution. Gladly I came across the answer on R. Aaron Zupancic’s blog.

Following his article I created a little utility that I hope could make using Aaron’s approach a little more flexible.
Basically it’s an aspx page (you can download it here SelectWebSite.zip) that allows you to select a Web Project and run the ASP.NET Web Site Administration Tool against it.

1. Please follow Aaron’s article to create a virtual directory for %WINDIR%\Microsoft.NET\Framework\v2.0.50727\ASP.NETWebAdminFiles

  • Create a new virtual directory that references
    %WINDIR%\Microsoft.NET\Framework\v2.0.50727\ASP.NETWebAdminFiles.
  • Make sure that the appopriate version of ASP.NET is
    used.
  • On the directory security tab, disable anonymous
    access.

2. Then set the default document name to SelectWebSite.aspx

3. Download SelectWebSite.zip, un-zip and copy it to %WINDIR%\Microsoft.NET\Framework\v2.0.50727\ASP.NETWebAdminFiles

4. Make sure that the user account that runs Asp.Net has “Modify” permissions on the Asp.Net project directory and file that you want the WSAT to administer.

To check what account (or group) is used

  • Create an .aspx file
  • Copy the following code to it

<%@ Page Language=”C#” %>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

<html xmlns=”http://www.w3.org/1999/xhtml” >
<head runat=”server”>
<title>Untitled Page</title>
</head>
<body>
<form id=”form1″ runat=”server”>
<div>
<% Response.Write(System.Security.Principal.WindowsIdentity.GetCurrent().Name); %>
</div>
</form>
</body>
</html>


  • Place it in a virtual directory of your IIS server
  • Run this page with a browser
  • Note the ID that appears on the page
  • Grant that ID “Modify” permissions on the Asp.Net project


4. Run you browser and point it to the newly created virtual directory. It should display
SelectWebSite.aspx

5. You can add the URL to your “Favorites” or “Bookmarks” and call it up when you need to run Asp.Net Web Site Administration Tool for a particular Asp.Net app you are developing.

SelectWebSite.zip (1.1 KB)

Categories: Asp.Net Tags:

Asp.Net_SessionID Head Ache

June 24th, 2007 No comments

It took me ages to figure out why Request.Cookies[“ASP.NET_SessionID”]  was always ‘null’ in my attempts to learn about its behaviour.

For “ASP.NET_SessionID” to materialise – Page.Session MUST be written to!

Categories: Asp.Net Tags:
highslide for wordpress