Web Dev Matters and Me

Web Development Matters - HTML, XML, C#, .NET, AJAX/Javascript(jQuery), CSS, XML-XSLT

ME - LIFE,Philippines, Tokyo, ECE, PhilNITS/JITSE,情報処理, 日本語

things about Philippines, gaming, C# development and web development, how to make money in stock trading

Web Dev Matters and Me

Configuration files - which is for what

When we are developing applications, one of the considerations that we do is to make some configurable sections that will allow anyone to change how the application run without modifying the codes. app config for window based applications and web.config for web applications. how about for a SQLCLR? they are located in sqlservr.exe.config. This can be located easily by looking at the installation folder of SQL and find the Binn folder. Look for the latest version of SQL (you might see 8.0, 9.0, 10.0).

Now, how these config files take effect is quite tricky. For a web.config hosted in IIS, you must reset the IIS first, thru the IIS GUI or by running iisreset in command prompt. As for the machine.config, you must restart the machine, which means you should be careful deciding to shutdown a machine, especially if it is used as a server. For sqlserver configs, there is no need to restart the machine, as changes take effect after restarting the SQL Server service (Start> Run > services.msc     then scroll to the sqlserver service).

A .NET Framework error occurred during execution of user-defined routine or aggregate

Msg 6522, Level 16, State 1, Procedure, Line 1
A .NET Framework error occurred during execution of user-defined routine or aggregate :
System.TypeInitializationException: The type initializer  threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.ServiceModel.WSReliableMessagingFebruary2005Version' threw an exception. ---> System.IO.FileLoadException: Could not load file or assembly 'System.Runtime.Serialization, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. Assembly in host store has a different signature than assembly in GAC. (Exception from HRESULT: 0x80131050) See Microsoft Knowledge Base article 949080 for more information.
System.IO.FileLoadException:
   at System.ServiceModel.WSReliableMessagingFebruary2005Version..ctor()
   at System.ServiceModel.WSReliableMessagingFebruary2005Version..cctor()
System.TypeInitializationException:
   at System.ServiceModel.WSReliableMessagingFebruary2005Version.get_Instance()
   at System.ServiceModel.Channels.ReliableSessionBindingElement..ctor(Boolean ordered)
   at System.ServiceModel.WSHttpBindingBase.Initialize()
   at System.ServiceModel.WSHttpBinding..ctor()
   at ADMS.CommonClrSQL.StoredProcedures..cctor()
System.TypeInitializationException:
.
The statement has been terminated.

====================================================


Hi! If you are experiencing the above error, I'm guessing that you are trying to invoke a Webservice from SQL.  Just lately, I was involved with a task that performs some upgrade in SQL Server database and making the database make a call to a WCF Service. Now, the problem is, whenever the procedure/trigger will make a request to the hosted service, it will throw an Error. This made us sleepless for days, trying to figure out the fix, but fortunately we are able to make things working.

We are experiencing the above error because the assemblies deployed in GAC(Global Assemby Cache) is different to assemblies loaded to the database. So, we tried to load the assembly from the GAC itself. There is a caution here. Be sure that the correct version of dll is loaded. Since there are 32 bit and 64 bit assemblies, you must refer FIRST to the GAC MSIL then if the assembly doesnt exist in there, refer to the appropriate X-Bit folder(32 or 64).

Doing this solved our problem. On our case, the error message we get now points to a machine configuration. An endpoint entry which is a malformed XML must be removed or commented out, then have the machine restart (since it is machine configuration).

The questionable Question Mark (?) in C#

This under-rated character can make writing C#(or Perl) codes easier and simple.

It can either be a comparator or a null-conditional if-else statement, in just a single line.

it can simplify 

string SampleText;

if(Datetime.Now.Month == 12)
{
SampleText = "Christmas Month";
}
else
{
SampleText = "Some Other Month";
}


into

string SampleText = Datetime.Now.Month == 12 ? "Christmas Month" : "Some Other Month";


or much even this

string SampleText;

if(passedParameter != null)
{
SampleText = passedParameter;
}
else if (passedParameter1 != null)
{
SampleText = passedParameter1;
}
else if (passedParameter2 != null)
{
SampleText = passedParameter2;
}
else if (passedParameter3 != null)
{
SampleText = passedParameter3;
}
else
{
SampleText = string.Empty;
}
to simple



string SampleText = passedParameter ?? passedParameter1 ?? passedParameter2 ?? passedParameter3 ?? String.Empty;


and this is not limited to strings, it also applies to Objects.


More to share as we go to the world of coding (^-^)

Javascript is under rated, but powerful

On my way home, I had a chance to talk to a fellow Web Developer working at a bank. She holds web projects of a small IT department of the bank. She is very confident at how she handles server scripts and out of somewhere said, I won't have to worry about all those client side scripts because it will always run at the back end.

While a bit worried, I said that she might haven't heard of XSS(or CSS, cross site scripting). Probably she haven't tried few developments on the wild internet, but actually a small javascript code can override functions, even prevent a server control's default action to a new one, thru Javascript. I agree that, server side validation is powerful, but javascript is like a shoelace, that on a hand of an assassin, can even be deadly.

I have posted an article here about PRC website hacking incident. I believe it was done thru SQL Injection and XSS (by injecting script tag). Reputation of PRC website for google is laced with malicious attempts to download harmful materials.

For those who doesn't acknowledge what Javascript can do. It can even change your web application to post to a remote server and steal informations. That's a good reason to do validation, both client and server side.

T4 in ASP.NET MVC 2

One of the dilemmas I had with ASP.NET development is that, ASP.NET  render server controls their own way, stuffs like Gridviews, Radio button list, Check box list, etc. Sure it does the work and saves time, but not long enough, until future changes are considered. Also, flexibility in manipulating front-end things (CSS) would be hard, without altering the markup, adding classes or ids, etc...

I really liked ASP.NET server controls and data binding. Those made my life easy, but because of poor rendering technique, it is a disappointment (at least for me) to see that my markups are rendered poorly and non-standard compliant. (i never imagined stuffing things sandwiched by a span tag).

good thing, there is a nice feature for ASP.NET MVC that prevents me from, seemingly re-invent the wheel (i hate re-writing custom server controls when all it needs is some mark-up changes). Code Templates T4 (Text Template Transformation Toolkit) will make rendering easy and gives you full control on the mark-up.

these T4 is a format that expresses how a model will be rendered. So if you got a lot of datas to be displayed, it doesn't necessarily mean to render it as a table or nest controls inside span, etc...

So, once you got a View, just specify a T4 template that it will use for the model datas that it will display, and there you got it, a web application that implements a separation of concern, front end developers just deal with their CSS and javascripts.

Philippine Hostage taking ends in a bloody way

Another sad news that might hurt the economy of the Philippines. Due to some selfish ignorance, someone who was dismissed from his duty just proved himself that he is worthy of being kicked out of service. I just don't understand why people dismissed at their service would still have high-caliber weapons that will enable someone to do terrorist acts.

Early morning, a tourist bus boarded by 22 Chinese citizens was hijacked by a Policeman in UNIFORM, carrying an M-16 rifle, ammunition and few pistols. Then, later posted something on the window of the bus, that seems to be asking for demands.

The hostage-taker was expelled from duty because of alleged involvement to drug related case and illegal distortion. He is HOPING to be enlisted again, but presumably rejected due to involvement to the mentioned crimes.

9 Chinese are allowed to go earlier and then on the midst of the rain, loud gunshots are heard from inside of the bus.

The hostage taker died on the assault and fortunately, not everyone on the bus was killed, as earlier stated by the driver.


But why does this thing happen? First of all, this is not a new incident. Years ago, somebody did this, and the aftermath, he was freed and the hostages (filipino kids) are even granted scholarships. I kept on asking myself, why things like this happen? How many lives needs to be taken first? How many loses do Philippines have to endure?

I hope somebody can resolve this. Fight people who masquerade themselves as justice.

*UPDATE*

8 Chinese Nationals are confirmed dead.
7 Chinese wounded.
1 bystander, a Filipino boy was wounded.

Hong Kong issued a travel advisory to HK residents to avoid Philippines.

jQuery extends jQuery Mobile Framework

With constant birth of new Mobile devices, checking for changes to web development becomes a task that web developers need to do, whenever something big will be released in the market. Many are hoping that HTML 5 will address rendering issues and make it consistent for both mobile and desktop/laptop devices. Probably, CMS developers will make some changes on how each data are rendered.

While the display consistency will be done in no time, jQuery Mobile framework will probably make UI development easy. I have used the jQuery UI in various Web Applications I developed that doesn't have enough time to design screen UI, and the result is a user-friendly UI that is also XHTML compliant.

CD-R King's Wi-Fi + Bluetooth USB Combo Dongle in Ubuntu 10.4

Since my mom's computer is quite outdated, running on Intel's Pentium 4 1.8GHz + 256MB RAM, I decided to install Ubuntu side by side. The reason for this is that, most of my mom's friends are already on facebook and she asked me how to setup an account for this, which eventually requires stable internet connection. (I'm not letting her use dial-up internet and feel more stressed).

Developing .NET Web applications using MonoDevelop

Just these past days, I considered installing Ubuntu to one of my Notebook and, after finally upgrading it to Ubuntu 9.10, the next thing I planned is to use some visual-studio like API for Ubuntu.



I liked Ubuntu's environment. Just beside the panel that displays Date and Time, you can also see the temperature and weather of your current city. Something I would like to see in Windows OS, without using Widgets, as introduced in Vista.

you can download monodevelop at monodevelop.com

reference : VAIO Type P Guide for XP, Ubuntu, Vista and Windows 7

HTML 5 Ruby Annotation.

A complete ruby annotation in HTML 5 consist
of ruby, rt and rp tag.


<ruby>


<rt>
わたし(watashi)
</rt><rp>Sorry your browser doesn't support HTML5</rp>
</ruby>


as we all know, ruby tag is to add ruby annotation in our HTML, rt is the text that was supposed to be, the
pronounciation guide. rp tag is optional, since it won't show up if the browser doesn't support ruby annotation, but not if the browser doesn't support HTML 5. If the browser can't, it will STILL DISPLAY THE RP TAG along with other tags, as if they are unknown HTML elements.



Twitter got injected with malformed HTML

Just a few minutes ago, I checked twitter just to see that, somebody have successfully enter some counter-HTML to prevent twitter from displaying contents. It seems that they made it this fair by adding extra closing tags,like to close other elements, giving them way to add new tag elements.

even the links are altered. Probably, these users are really pissed at the  "Whale image"

Twitter over Capacity - "Stupid Whale"

Lately, many disgruntled twitter users got pissed by this image, that they even trend a topic "Stupid Whale"

Routing web traffic

With few SEO things I had in mind, I'm able to produce big changes from site deployment that took about 1 month. Although I'm a bit surprised about the result, I'm not yet satisfied since I believe there is a much better way of having these figures.








5 Ways to tell major search engines that you're serious in getting the #1 search result

Aside from good HTML element arrangements, optional attributes, additional meta elements , canonical or backlinks, you must have properly told major search engines where to find those pages, or at least tell them that those pages exist. How? Using sitemaps. yes, SITEMAPS. If you think having one is enough, then maybe it is, for a normal website. But if you are really dedicated to reach the #1 spot, have you tried these:

Found the culprit!

From my previous post, the culprit was really on the server.

Analysis of recent injection attack

Just few minutes ago, one of the websites I currently own was attacked. Since I am expecting this really soon (because the site is gaining high traffic recently), I wonder how it is made possible.

Random Check for Browsers


A random check, I tried to put a test page on one of domains I control. I really liked the results because most people are getting smarter now by using Chrome.







Random resolution check


a random check of web resolution. there is no 640x480 and 800x600 anymore. I wonder what will happen to all of those ICE BOX (one that stays always on left, leaving a large area of website WASTED!








Google's PACMAN Game - PAC-MAN 30th Anniversary

PAC-MAN 30th Anniversary











Overall optimization

At first, I only thought that this applies most at Back-End, but actually an overall task that needs to be done.  In case of websites (except stateless) needs overall optimization: (based on my exp)


Code-Behind
-prevent unnecessary object creation. (Consider re-use, Singleton class to hold global variables)
-don't develop with the purpose of using design patterns. Use design pattern where applicable.
-unnecessary try ? catch ? would affect performance.

Database
-1st thing to be considered. most of the time, the bottleneck
-don't make unnecessary select (overused *). just take out the fields that you need.
-dont forget to close connection when not needed.

Client-Side
-cache the output for non-dynamic files
-static & dynamic compression, gzip
-optimize external files (js, css)
-consider sprite-technique on CSS layout (example : 足掛かり.com uses sprite techniques that changing CSS class wouldn't require another download)
-un-comment and compress JS and CSS

HTML 5 is here!

I've tried to check for new HTML 5 tags and I'm surprised that it is turning just like the version 1 of Silverlight. If you're not familiar with Silverlight, it is used for making some animations but more on clientside, since all you can do on version 1 was XAML and javascript.

Web Optimizations

I just deployed the web project that took almost 3 months to deploy, thanks to the CC problems I had. Things seems to be fine and I think I would be spending some time to write some contents.

But before that, I wanted to optimize few things that are not visible until it was deployed in a shared remote server.

Configuring website rules in IIS Manager

Managing websites can be a pain in the neck. Sometimes you'll find yourself fixing some broken links, editing style sheets because of routing side-effects and even managing bandwidth limit. You probably won't be fit for a web admin task if you can't make a solution for all of those things. Good thing there are few tips that you can do now.

Twitter now gets special results in Google

Tweets from twitter doesn't appear as regular pages now.


March 33 Anniversary (April 2) for custom firmware in PSP

April 1 usually for fooling other people, but if you have tried a custom firmware for your PSP, you might notice that you'll be dealing with few 3s.











Facebook isn't designed as robust as it seems...

My understanding of a robust application is that under strict conditions, it should degrade gracefully. That's why it is a good practice to design from basic HTML, and later upgrade to an AJAX rich version. If done this way, even if CSS, Javascript failed to load, the user will still be able to at least submit few things.

Maybe it is good to simply do AJAX rich applications, since big sites like facebook doesn't consider graceful degradation.

FB Connect