The Temple of Fu

code, systems and games

Archive for March 2010

ASP.Net Events

leave a comment »

A full list of all events that occur in an ASP.NET application, from standard modules, to the page, master page, page controls and master page controls.

What When
HttpApplication.BeginRequest
HttpApplication.AuthenticateRequest
HttpApplication.PostAuthenticateRequest
HttpApplication.AuthorizeRequest
HttpApplication.PostAuthorizeRequest
HttpApplication.ResolveRequestCache
HttpApplication.PostResolveRequestCache
HttpApplication.MapRequestHandler
HttpApplication.PostMapRequestHandler
HttpApplication.AcquireRequestState
HttpApplication.PostAcquireRequestState
HttpApplication.PreRequestHandlerExecute
Page.FrameworkInitialize
Page.InitializeCulture
Page.OnPreInit
MasterPage.FrameworkInitialize
MasterPageControl.FrameworkInitialize
PageControl.FrameworkInitialize
MasterPageControl.OnInit
PageControl.OnInit
MasterPage.OnInit
Page.OnInit
Page.OnInitComplete
Page.LoadPageStateFromPersistenceMedium If IsPostBack
Page.LoadControlState If IsPostBack
MasterPageControl.LoadControlState If IsPostBack, RegisterRequiresControlState was called and control state contains elements
PageControl.LoadControlState If IsPostBack, RegisterRequiresControlState was called and control state contains elements
MasterPageControl.LoadViewState If IsPostBack and ViewState contains elements
PageControl.LoadViewState If IsPostBack and ViewState contains elements
Page.OnPreLoad
Page.OnLoad
MasterPage.OnLoad
MasterPageControl.OnLoad
PageControl.OnLoad
{PageControl|MasterPageControl}.OnCustomEvent If a custom event was fired on a control declared on the page/master page
{PageControl|MasterPageControl}.OnBubbleEvent If a custom event was fired on a control declared on the page/master page
{Page|MasterPage}.OnBubbleEvent If a custom event was fired on a control declared on the page/master page
Page.OnBubbleEvent If a custom event was fired
Page.OnLoadComplete
ClientCallbackControl.RaiseCallbackEvent If in a client callback asynchronous request
ClientCallbackControl.GetCallbackResult If in a client callback asynchronous request
Page.OnPreRender If not in an asynchronous postback
MasterPage.OnPreRender If not in an asynchronous postback
MasterPageControl.OnPreRender If Visible
PageControl.OnPreRender If Visible and not in an asynchronous postback
Page.OnPreRenderComplete If not in an asynchronous postback
Page.SaveControlState If not in an asynchronous postback and RegisterRequiresControlState is called for the page and control state contains additiona values
MasterPageControl.SaveControlState If not in an asynchronous postback and RegisterRequiresControlState is called for the master page control and control state contains additiona values
PageControl.SaveControlState If not in an asynchronous postback and RegisterRequiresControlState is called for the page control and control state contains additional values
Page.SaveViewState If not in an asynchronous postback
MasterPage.SaveViewState If not in an asynchronous postback
MasterPageControl.SaveViewState If not in an asynchronous postback
PageControl.SaveViewState If not in an asynchronous postback
Page.SavePageStateToPersistenceMedium If not in an asynchronous postback
Page.OnSaveStateComplete If not in an asynchronous postback
Page.Render If not in an asynchronous postback
MasterPage.Render If not in an asynchronous postback
MasterPageControl.Render If Visible and not in an asynchronous postback
PageControl.Render If Visible and not in an asynchronous postback
Page.OnCommitTransaction If Transaction = Required or RequiresNew and a transaction was committed or
no transaction was created
Page.OnAbortTransaction If Transaction = Required or RequiresNew and a transaction was rolled back
MasterPageControl.OnUnload
MasterPageControl.Dispose
PageControl.OnUnload
PageControl.Dispose
MasterPage.OnUnload
MasterPage.Dispose
Page.OnUnload
Page.Dispose
HttpApplication.PostRequestHandlerExecute
HttpApplication.ReleaseRequestState
HttpApplication.PostReleaseRequestState
HttpApplication.UpdateRequestCache
HttpApplication.PostUpdateRequestCache
HttpApplication.LogRequest
HttpApplication.PostLogRequest
HttpApplication.EndRequest
HttpApplication.PreSendRequestHeaders
HttpApplication.PreSendRequestContent

References:http://weblogs.asp.net/ricardoperes/archive/2010/01/04/asp-net-events.aspx

Advertisements

Written by lordfu

March 30, 2010 at 12:19 pm

Posted in ASP.Net, Development

Move IIS Data Directory script

leave a comment »

I can’t remember how I got this script or from where but I have used it twice now so I am posting it here for others. If you are the original script author please let me know and i would be glad to tag it as such!

'------------------------------------------------------- '
' FILE: moveIISDataDirectory.vbs
' Used to migrate Web Data (FTP, WWW, SMTP) from drive C:\INETPUB to drive D:\INETPUB.
' This script can be modified to meet the need of any customers.
' Please do not remove this header info though.
'--------------------------------------------------------

'Stop IIS services before continuing

Set WSHShell = Wscript.CreateObject("Wscript.Shell")
WSHShell.PopUp "Stopping all Internet Services..."
ret = WshShell.Run ("net stop iisadmin /y", 1, TRUE)

If ret = 0 then
WSHShell.PopUp "IISADMIN service was stopped successfully, continuing"
'restart()
else
WSHShell.PopUp "IISADMIN failed to stop successfully. The error code is " & ret Wscript.Quit 1
end if

' Modify IIS Metabase Properties for new data location
Dim params(7)
Dim x, ret
Dim params2(3) Params(0) = "w3svc/1/root/path d:\inetpub\wwwroot"
Params(1) = "w3svc/1/root/scripts/path d:\inetpub\scripts "
Params(2) = "w3svc/1/root/iissamples/path d:\inetpub\iissamples"
Params(3) = "msftpsvc/1/root/path d:\inetpub\ftproot"
Params(4) = "smtpsvc/1/BadMailDirectory d:\inetpub\mailroot\BadMail"
Params(5) = "smtpsvc/1/PickupDirectory d:\inetpub\mailroot\Pickup"
Params(6) = "smtpsvc/1/QueueDirectory d:\inetpub\mailroot\Queue"
Params(7) = "smtpsvc/1/DropDirectory d:\inetpub\mailroot\Drop"

Set WshSysEnv = WshShell.Environment("PROCESS")

For Each x In Params
ret = WSHShell.Run ("cscript.exe " & "c:\inetpub\adminscripts\adsutil.vbs SET " & x, 1, TRUE)
Next

' Verify Settings were successfully applied
If ret = 0 then
WSHShell.PopUp "The new metabase settings have been successfully updated. The new Web Data path is D:\inetpub"
else
WSHShell.PopUp "The Configuration changes failed. The error code is " & ret Wscript.Quit 1
end if

wscript.Sleep 5000

' Move Data to new location (D:\inetpub) using xcopy.exe (this can be changed from xcopy to move so the data is actually moved from current locale)
ret = WSHShell.Run ("xcopy c:\inetpub d:\inetpub\ /s /e /q" , 1, TRUE)

If ret = 0 then
WSHShell.PopUp "The data has been successfully moved to d:\inetpub"
else
WSHShell.PopUp "The data move failed. The error code is " & ret Wscript.Quit 1
end if

' Update Web Catalog to be for d:\inetpub 'Stop Content Index Service
Set WSHShell = Wscript.CreateObject("Wscript.Shell")
WSHShell.PopUp "Stopping Index Service..."
ret = WshShell.Run ("net stop cisvc", 1, TRUE)

If ret = 0 then
chgeCat()
else
WSHShell.PopUp "Content Index service failed to stop successfully. The error code is " & ret Wscript.Quit 1
end if

Function chgeCat()
Set WshShell = WScript.CreateObject("WScript.Shell")

'Delete Catalogs '
WshShell.RegDelete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ContentIndex\Catalogs\Web\"

' Delete Web Catalog. '
WshShell.RegDelete "HKLM\SYSTEM\CurrentControlSet\Control\ContentIndex\Catalogs\System\"

' Delete System Catalog. 'Modify existing Web catalog entry
WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\ContentIndex\Catalogs\Web\Location", "d:\inetpub"
WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\ContentIndex\Catalogs\Web\IsIndexingW3Svc", 1, "REG_DWORD"
end function

'Start Services (WWW, FTP, SMTP, CISVC)
Set WSHShell = Wscript.CreateObject("Wscript.Shell")
WSHShell.PopUp "Attempting to restart stopped Services..."
Params2(0) = "w3svc"
Params2(1) = "msftpsvc"
Params2(2) = "cisvc"
Params2(3) = "smtpsvc"

For Each x In Params2
ret = WshShell.Run ("net start " & x, 1, TRUE)
wscript.Sleep 5000
Next

If ret = 0 then
WSHShell.PopUp "Services were started successfully, modifications complete"
else
WSHShell.PopUp "One or more services fail to start successfully. The error code is " & ret Wscript.Quit 1
end if

Written by lordfu

March 25, 2010 at 3:54 pm

The operation could not be performed because the OLE DB provider ‘SQLOLEDB’ was unable to begin a distributed transaction

with 2 comments

A developer at work today encountered the error below when trying to insert stored procedure results into a temp table where the stored procedure contains a reference to a linked server. Well fortunately he fixed it and shared his information so I am sharing it with you.

The operation could not be performed because the OLE DB provider 'SQLOLEDB' was unable to begin a distributed transaction.
[OLE/DB provider returned message: New transaction cannot enlist in the specified transaction coordinator. ]
OLE DB error trace [OLE/DB Provider 'SQLOLEDB' ITransactionJoin::JoinTransaction returned 0x8004d00a].

He enabled the MSDTC service but still received the error. In order to completely fix this error he had to perform the following to enable network access, by default the network access settings of MSDTC are disabled on new installations of SQL Server 2000 on computers that are running Windows Server 2003.

To work around this behavior, install network DTC access on both servers:

  1. Click Start, and then click Control Panel.
  2. Click Add or Remove Programs, and then click Add/Remove Windows Components.
    In the Components box, click Application Server, and then click Details.
  3. Click to select the Enable network DTC access check box, and then click OK.
  4. Click Next, and then follow the instructions that appear on the screen to complete the installation process.
  5. Stop and then restart the Distributed Transaction Coordinator service.
  6. Stop and then restart any resource manager services that participates in the distributed transaction (such as Microsoft SQL Server or Microsoft Message Queue Server).

References:
Microsoft Support

Written by lordfu

March 25, 2010 at 11:53 am

Posted in Database, MSSQL

Start MySQL daemon on boot

leave a comment »

In order to start the MySQL daemon at boot time one must add it to the system’s boot up process. Note this only works on SysV init runlevel systems.

Run the following command as root.

chkconfig mysqld on
or the more verbose where you specify the runlevel
chkconfig mysqld --level 2345 on

To clarify, a runlevel determines what services are started when a Linux computer is booted. When you boot into runlevel 1, only the core system files are loaded similar to Windows Safe Mode. Runlevel 2 is there if you want to create a custom runlevel the same as Runlevel 4. Runlevel 3 is what most servers boot to and it starts all of your services and other things required for a true multi-user environment. Runlevel 5 is for starting a GUI and this is what most desktop systems boot to.

You can then check that MySQL is enabled to start by running the following command. Again run this command as root.

chkconfig --list

That’s it!

Written by lordfu

March 20, 2010 at 11:26 pm

Posted in Database, MySQL, RedHats

Reset MySQL root password

with one comment


#service mysqld stop
#/usr/bin/mysqld_safe --skip-grant-tables &
#mysql --user=root mysql
mysql>update user set Password=PASSWORD('new-password-here') WHERE User='root';
mysql>flush privileges;
mysql>exit

Kill the mysqld_safe process

#fg
Ctrl+z

Then restart MySQL
#service mysqld restart

Written by lordfu

March 20, 2010 at 11:25 pm

Unable To Start Debugging on the Web Server because Integrated Windows Authentication is not enabled

leave a comment »

You ever received the error above?

To fix it open Start->Administrative Tools->Internet Information Services

Right click on the website that you are trying to enable debugging on and click “Properties”.

Then click the “Directory Security” tab.

Then click edit on “Anonymous Authentication and Access” control.

Check the box that says “Integrated Windows Authentication”

That should be it.

Written by lordfu

March 20, 2010 at 2:44 pm

ASP.NET – Write to Windows Event Log

leave a comment »

Ever have a need to write to the Windows Event log, in my case it was to get around debugger anomalies.

public partial class EventWireupPage : System.Web.UI.Page
{

protected void Page_Load(object sender, EventArgs e)
{
System.Diagnostics.EventLog.WriteEntry("ASPNET", "Page_Load");
}

protected void GridView1_RowCommand(object sender,GridViewCommandEventArgs e)
{
System.Diagnostics.EventLog.WriteEntry("ASPNET","GridView1_RowCommand");
}

}

Written by lordfu

March 20, 2010 at 2:42 pm

Posted in Development