Archive

Author Archive

Discount coupon for Application lifecycle management

Categories: Uncategorized

Change the framework version without restarting the W3SVC service

When changing the .NET version on the ASP.NET tab of IIS, this popup appears, asking to restart IIS, or run aspnet_regis -norestart to change the scriptmap without restarting.

1. Download metabase explorer, as part of the IIS6 resource kit here
 http://www.microsoft.com/DownLoads/en/details.aspx?familyid=56fc92ee-a71a-4c73-b628-ade629c89499&displaylang=en

2.  Run Metabase explorer, Select LM then W3SVC

3. Find the ID that matches the site you want to upgrade

4. Go to C:WINDOWSMicrosoft.NETFrameworkv4.0.30319 with Command Prompt

5. type aspnet_regiis.exe -norestart -s W3SVC/<ID>/ROOT where <ID> is from step 4.

6. Clicking the ASP.NET tab in IIS, it should now be .NET 4.

Categories: Uncategorized

Make a HTTP request from SQL server

**Update**

A better approach is listed here: https://blog.dotnetframework.org/2019/09/17/make-a-http-request-from-sqlserver-using-a-clr-udf/

sqlhttp

Here is a UDF that allows HTTP GET requests from SQL server, for example
select dbo.GetHttp(‘http://fiachsapp.appspot.com/&#8217;)

A few “Gotcha’s” are;
* The HTML Content must be less than 8000 bytes, otherwise you get the error:

  0x8004271A ODSOLE Extended Procedure    Error in srv_convert.

* The COM object WinHttp.WinHttpRequest.5.1 must be installed on the server, some typical variations are WinHttp.WinHttpRequest.5
and WinHttp.WinHttpRequest. A search for the CLSID in Regedit should find the one you are using.

* You have to enable OLE Automation on the SQL server as follows;
sp_configure ‘show advanced options’, 1;
GO
RECONFIGURE;
GO
sp_configure ‘Ole Automation Procedures’, 1;
GO
RECONFIGURE;
GO

Alter function GetHttp
(
@url varchar(8000)
)
returns varchar(8000)
as
BEGIN
DECLARE @win int
DECLARE @hr  int
DECLARE @text varchar(8000)

EXEC @hr=sp_OACreate ‘WinHttp.WinHttpRequest.5.1’,@win OUT
IF @hr <> 0 EXEC sp_OAGetErrorInfo @win

EXEC @hr=sp_OAMethod @win, ‘Open’,NULL,’GET’,@url,’false’
IF @hr <> 0 EXEC sp_OAGetErrorInfo @win

EXEC @hr=sp_OAMethod @win,’Send’
IF @hr <> 0 EXEC sp_OAGetErrorInfo @win

EXEC @hr=sp_OAGetProperty @win,’ResponseText’,@text OUTPUT
IF @hr <> 0 EXEC sp_OAGetErrorInfo @win

EXEC @hr=sp_OADestroy @win
IF @hr <> 0 EXEC sp_OAGetErrorInfo @win

RETURN @text
END

 

Categories: Uncategorized

Find when a stored procedure was last modified

A handy trick to find when a stored procedure was last modified is with this command;

SELECT * FROM [database].sys.objects WHERE type = ‘P’

This gives the following fields:

name 
object_id 
principal_id
schema_id  
parent_object_id
type
type_desc                                                   
create_date            
modify_date            
is_ms_shipped
is_published
is_schema_published

Categories: Uncategorized

How to: Make Thread-Safe Calls to Windows Forms Controls without delegates

If you try to update the UI of a windows form app with a thread spun off by the main thread you get an exception, Microsoft’s suggested solution is as follows;
private void SetText(string text)

{
// InvokeRequired required compares the thread ID of the
// calling thread to the thread ID of the creating thread.
// If these threads are different, it returns true.
if (this.textBox1.InvokeRequired)
{
SetTextCallback d = new SetTextCallback(SetText);
this.Invoke(d, new object[] { text });
}
else
{
this.textBox1.Text = text;
}
}

Which omits the code for the SetTextCallback delegate, which over time, can clutter up your application.

Instead, I would suggest using an Action<T> as follows:

var d = new Action<string>(SetText);




Categories: Uncategorized

DNS round robbin with failover

If you have two A records for the same subdomain in DNS, then the DNS server will alternate which ones it returns, in a round-robbin fashion.

I’ve noticed that NS records in DNS also work on a round robbin feature, NS records also alternate.

This implies that you could create a distributed load balancer with failover using only DNS

Server A ip (Multihomed; 1.1.1.1 and 1.1.100.1)
NS NS1.SERVER.COM
NS NS2.SERVER.COM
A NS1 1.1.1.1
A NS2 1.1.100.1
A www 1.1.1.1

Server B ip (Multihomed; 2.2.2.2 and 2.2.200.2)
NS NS1.SERVER.COM
NS NS2.SERVER.COM
A NS2 2.2.2.2
A NS1 2.2.200.2
A www 2.2.2.2

SERVER.COM delegated with nameservers NS1.SERVER.COM and NS2.SERVER.COM

Now, the A records are not load balanced but the NS records are.

So theoretically, a DNS client, connecting randomly to NS1 or NS2 will be given either 1.1.1.1 or 2.2.2.2 as an IP address, depending
on what nameserver it contacted.

If the DNS on NS1 goes down, then the client will automatically contact NS2. and be given server 2’s IP address. The logic being, that if the DNS
server is down, the webserver probobly is too.

In this case, the A records are not load balanced but the NS records are.

I assume this would not get past ZoneCheck for delegation of some top level domains like .fr, .de  or .no, but it might work for a .com

Categories: Uncategorized

How to break hash codes with Google

Hash codes are one way algorithims, and are supposted to be unbreakable, unless of course, you have access to Google, then
it’s simple…

Just search for

Site:reverse.me.uk + hashcode

I managed to retrieve a lost password that was Hashed in a MySQL database..

mysql> select * from admins;
+——–+———-+———————————-+
| userid | username | password                         |
+——–+———-+———————————-+
|      4 | admin    | 1752017eea2e45fbXXXXXXXXXX |
|      5 | nktest   | 1752017eea2e45f1fXXXXXXXXXX |
+——–+———-+———————————-+

– And, yes, I’ve put X’s in there, just in case…

the site, reverse.me.uk has about 5 million hash codes, covering most of the shorter passwords, so beware!

Categories: Uncategorized

An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode.

An ASP.NET setting has been detected that does not apply in
Integrated managed pipeline mode.

I was using a component called FreeTextBox, which adds the following line into Web.Config

<httpHandlers>
            <add verb="GET" path="FtbWebResource.axd" type="FreeTextBoxControls.AssemblyResourceHandler, FreeTextBox"/>
</httpHandlers>

This however, is not compatible with IIS7,

Quick fix is to take the app pool out of Integrated mode. So, go to your website on IIS 7, Press "Advanced Settings", and it will say the name of the Application Pool. Then go to application pools, click on the offenting pool, and select "Advanced Settings", then under "Managed Pipeline mode" change it
from Integrated to Classic. No restart of IIS is required.

Categories: Uncategorized

Casting a float to a double

Categories: Uncategorized

Http status 417: expectation failed

An interesting problem I found when calling a web service was this error:

Http status 417: expectation failed

Reading posts on the net said this could be a proxy problem, but I wasn’t using a proxy, so this wasn’t it. The solution appeared
as this little gem:

ServicePointManager.Expect100Continue = false;

 

I guess the server must have responded with a HTTP 100, which was not expected by the client, or vice versa. The Webservice
itself appeared to be hosted on a non-.net platform.

Categories: Uncategorized