Saturday, October 07, 2006

Ajaxpro and Yahoo! JavaScript Library

There are a lot of great JavaScript libraries available that are used be developers to add Ajax and Web 2.0 to their web sites. While AjaxPro is optimized to run on all web browsers including Windows Mobile devices I got some requests on supporting the Yahoo! JavaScript libraries. I have done some internal changes that will allow you do use the Yahoo! JavaScript files instead of the generated files from AjaxPro. Because there is no JSON parser in the Yahoo! lib I'm using the json.js written by Douglas Crockford. But first have a look at the ASP.NET page (C#):

[AjaxPro.AjaxNamespace("Home")]

public partial class _Default : System.Web.UI.Page

{ [AjaxPro.AjaxMethod]
public static string HelloWorld(string name)
{
return "Hello " + name;
}

protected void Page_Load(object sender, EventArgs e)
{
// AjaxPro.Utility.RegisterTypeForAjax(typeof(_Default));
}
}

The only difference is removing the RegisterTypeForAjax call which will include the AjaxPro JavaScript files to the current page. Now, have a look at the client-side JavaScript source code:

The first object callback is used to run an asyncronous XmlHttpRequest request. The sucsess function will be called when the requests is finished. Next we have the arguments we need for the .NET method HelloWorld. If you look in the C# source code above you will see the correct notation of the argument name:

var args = {};
args.name = "Michael";

To call an AjaxMethod AjaxPro is using a http header x-ajaxpro-method. In my example you have set this value to HelloWorld:

YAHOO.util.Connect.initHeader("x-ajaxpro-method", "HelloWorld");

Now, we can invoke the AjaxMethod using the YAHOO.util.Connect method. AjaxPro needs the arguments in the http body as a JSON string. For this I use the method toJSONString() which is included in the json.js from Douglas.
var connectionObject = YAHOO.util.Connect.asyncRequest("POST",
"ajaxpro/_Default,App_Code.ashx", callback, args.toJSONString()

Get more information

Can't find what you're looking for? Try Google Search!
Google
 
Web eshwar123.blogspot.com

Friday, October 06, 2006

Configuring Microsoft Log Parser to look for 500 server errors

This Log Parser query assumes that the logs are in c:\logs\web and that IIS has been configured to log in Microsoft's W3C extended log format.  With modified syntax this query could be used to analyze log files in other formats.

The query can be run from a DOS prompt within the Log Parser installation folder.  To save excessive typing or pasting into command prompt windows the whole query can be saved as a .bat file.

logparser "SELECT [cs-uri-stem], [cs-uri-query], Count(*) AS [Hits]
FROM c:\logs\web\ex*.log
WHERE sc-status = 500
GROUP BY [cs-uri-stem], [cs-uri-query]
order by [hits], [cs-uri-stem] DESC" -rtp:-1 -i:iisw3c

Once the query has been put into a batch file (Find500Errors.bat), it can be run using the following when typed at the command prompt (which will produce an output file called 500Errors.txt).

Find500Errors.bat > 500Errors.txt

The query output

The 500 server errors Log Parser query shown above creates a report like the following:

/w/Products.ASPNETDocumentationTool.asp|-|ASP_0113|Script_timed_out 18

/w/Products.ASPDocumentationTool.asp |-|ASP_0113|Script_timed_out 18

/w/Products.IndexServerCompanion.SampleSearch.asp|33|800a01f4|Variable_is_undefined:_'LogEvent' 11

/w/News.asp|-|ASP_0113|Script_timed_out 5

/w/Affiliates.asp|-|ASP_0113|Script_timed_out 5

/w/Products.IndexServerCompanion.SampleSearch.aspquery=the&I1.x=0&I1.y=0|126|80041605|
The_query_contained_only_ignored_words._ 4

/w/Products.IndexServerCompanion.Download.aspAction=Step2|48|800a0bcd|
Either_BOF_or_EOF_is_True__or_the_current_record_has_been_deleted.
_Requested_operation_requires_a_current_record. 4

/w/Products.ASPDocumentationTool.Screenshots.asp |-|ASP_0113|Script_timed_out 4

/w/Downloads.asp |108|8007000e|[Microsoft][ODBC_Microsoft_Access_Driver]_Not_enough_space_on_temporary_disk. 2

/w/Downloads.asp |108|80004005|Unspecified_error 2

For each of the errors it reports the page on which the error was encountered, the details of the error and the number of times each page reported the particular error.  Due to the query's order by clause, the most common errors are listed first.  The group by clause is used to group identical errors from each page.

As may be seen from this sample output, a comprehensive overview of the website's problems may be gained.  In this particular example the number of timeout errors would indicate that the website has significant performance issues.  Other errors in this sample include an ASP coding error ("Variable_is_undefined") and an Indexing Services error ("The_query_contained_only_ignored_words").  Fixing these errors could lead to significant enhancement of the user's experience of the website.

Get more information

Can't find what you're looking for? Try Google Search!
Google
 
Web eshwar123.blogspot.com

Working with DBISAM an embedded database engine using Microsoft .NET

DBISAM is a word that may seem new for many of us and many would be astonished to know that it is a database.  Like any other database, it has the ability to maintain huge amounts of data.  This article aims at providing an overview of DBISAM and the ways we can interact with the database through .NET. DBISAM is an embedded database engine which is available for programming languages that can use ODBC for data access.  DBISAM can be used as a single-user, multi-user or client-server engine.

General Architecture

DBISAM is session based where each session is equivalent to a virtual user.  In a given application there can be many active sessions.  The sessions are of 2 types.

· Local Session: A local session can directly access the database tables via Windows or Linux APIs to the local storage medium.

· Remote Session: A remote session uses sockets to communicate to a database server over a network using TCP/IP protocol.

The main drawback of DBISAM is that it does not support Referential Integrity.

Databases

DBISAM uses the physical directories in Operating System’s file system to represent databases. The tables in DBISAM are represented by three physical files in the database.

· .dat (Data Files) which are the actual tables in the Database that store records.

· .idx (Index Files) which store index definitions and pages.

· .blb (BLOB Files) that store BLOB blocks related to tables.

Working with DBISAM

After knowing a bit about database structure, let us put our hands on the programming part with relation to .NET.  As every database has accepted SQL as the standard language for querying, so too has DBISAM.  We do not need to worry about syntax; our same old concept on SQL will work fine here.  Now to connect to the DBISAM Database from our application, we need the DBISAM ODBC driver.  It is an ODBC level 3 driver.  The driver works with Microsoft Data Access Components (MDAC) version 2.7 or higher and many other applications including .NET Applications.

Missing Features

There are still a few things missing from the driver like support for bulk operations and a few ODBC extended scalar functions (UNION, INTERSECT, LIKE, etc).

Using ODBC Driver

To use the ODBC Driver we can either setup a DSN which we access from our application or can directly access the database through a connection string from our application.

Depending on our application need and location of the database (local or remote), the connections may vary.  It can be either done through a DSN or we can use a connection string to connect to the database.

Connection String

For direct connection strings the Keywords play a major role and are case sensitive.  The Connection String Keywords available in DBISAM ODBC Driver are as follows:

· DRIVER: It specifies the ODBC driver name used.

· ConnectionType: Depends on the connection, i.e. Local or Remote.

· CatalogName: Specifies the name of the database.

These were the required Keywords for both Local and Remote Connections.  The following keywords are required only for Remote connections.

· UID: Specifies the User ID for the remote connection.

· PWD: Specifies the password for the remote connection.

· RemoteHostName: Specifies the Host name of the remote Database server.

· RemoteIPAddress: Specifies the IP address of the remote Database Server.

From the RemoteHostName or RemoteIPAddress above, any one is used.

Get more information

Can't find what you're looking for? Try Google Search!
Google
 
Web eshwar123.blogspot.com

XAML - Microsoft's new markup language

EXtensible Application Markup Language (XAML) which is pronounced as Zamel is Microsoft's new markup language to define dynamic or static user interfaces for .NET applications.  XAML will be used in Windows Vista to design user interfaces, but can be applied to Windows XP or Windows 2003 as well. XAML comes to separate the UI code from application logic code and is very similar to MVC.  XAML is tied to Windows Presentation foundation (codenamed Avalon) to build a whole user interface in .NET 3.0 and Windows Vista.

XAML is an XML child indeed.  Every XAML code must be a well-formed XML file and XAML inherits all XML definitions and rules.  We can consider it as the last part of a chain that contains HTML, XHTML and other markup languages for UI.

What makes XAML different from other XML children is what it represents.  Every XAML element represents a .NET CLR class.  This lets you to extend and work on XAML easily. The model that XAML in conjunction with Windows Presentation Foundation provides to let developers design a rich user interface is similar to code behind and code inline model in ASP.NET. This means you can put your application logic in a separate file or embed it inline in XAML file itself. XAML files will be compiled to BAML files.  The advantage of BAML is it is smaller than XAML and is easier to read so it is faster to load.

Advantages of XAML

In addition to all benefits that XML or actually a markup language provides, XAML has some major and minor advantages; some of them are here:

· Designing a user interface is easier with XAML.

· Code for XAML is shorter than code for previous UI designing techniques and you will see it in action.

· XAML designed user interfaces are easier to transfer and present in other environments.  For example, you can present your UI on the web or a Windows Client easily.

· Designing a dynamic UI is absolutely easier with XAML.

· XAML enables a new world for UI designers and lets all designers build user interfaces without having any knowledge about .NET development.  This helps end users to see better user interfaces in the near future.

XAML Development Tools

To start developing for XAML and Windows Presentation Foundation, you need to have some tools in hand.  Do not forget that this article is written some weeks after the release date of .NET Framework 3.0 RC1.  You can start developing XAML and WPF on Windows Vista, Windows XP or Windows 2003.

You need to download WinFX SDK and Visual Studio 2005 Extensions for WinFX.  Although by installing WinFX SDK you have a cool tool to develop for XAML, Visual Studio Extensions can enable a visual designer and Intellisense, and great debugging features.  I recommend downloading VS 2005 Extensions for WinFX if you have it installed on your system.

Of you do not have it, do not worry because WinFX SDK comes with an editor for XAML which is named XAMLPad.  This editor lets you to type and edit XAML markup then it generates the UI for you.  It also has some debugging features.

There are some other tools available by Microsoft or community for XAML development:

· Microsoft Expression "Sparkle Interactive Designer"

· MyXaml

If you are using some tools like XamlPad to write your XAML codes, you can use MSBuild to compile them, but if Visual Studio is your primary IDE for this purpose it builds them on the fly for you.

Get more information

Can't find what you're looking for? Try Google Search!
Google
 
Web eshwar123.blogspot.com

Thursday, October 05, 2006

Get access to paid sites by being a Google spider

Ever experienced this? You ask Google to look something up; the engine returns with a number of finds, but if you try to open the ones with the most promising content, you are confronted with a registration page instead, and the stuff you were looking for will not be revealed to you unless you agree to a credit card transaction first....

The lesson you should have learned here is: Obviously Google can go where you can't.

Can we solve this problem? Yes, we can. We merely have to convince the site we want to enter, that WE ARE GOOGLE.
In fact, many sites that force users to register or even pay in order to search and use their content, leave a backdoor open for the Googlebot, because a prominent presence in Google searches is known to generate sales leads, site hits and exposure.
Examples of such sites are Windows Magazine, .Net Magazine, Nature, and many, many newspapers around the globe.
How then, can you disguise yourself as a Googlebot? Quite simple: by changing your browser's User Agent.
Copy the following code segment and paste it into a fresh notepad file. Save it as Useragent.reg and merge it into your registry.

Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Mcft\Windows\CurrentVersion\Internet Settings\5.0\User Agent]
@="Googlebot/2.1"
"Compatible"="+http://www.googlebot.com/bot.html"

Voila! You're done!

You may always change it back again.... I know only one site that uses you User Agent to establish your eligability to use its services, and that's the Windows Update site...
To restore the IE6 User Agent, save the following code to NormalAgent.reg and merge with your registry:

Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Mcft\Windows\CurrentVersion\Internet Settings\5.0\User Agent]
@="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"

Also Check the spell of Mcsft in your registry editor.
Can't find what you're looking for? Try Google Search!
Google
 
Web eshwar123.blogspot.com