Archive for category ASP.NET

Mono doesn't support LINQ to Entity framework

Recently, I’ve stopped paying for the Windows VPS hosting service for one of my projects – mobochats.com. I’d like to find a free hosting service that can support the following:

  • .NET 3.5
  • LINQ to Entity
  • SQL Server

It turned out that Somee.com facilitates these criteria very well! The only thing that I didn’t like was the forced advertisements which screwed up some of the html styles on the iPhone portion of the application.

Then, I’ve tried two other free ASP.NET hosting services – 0000free.com and HelioHost.org. The two services are very similar. Both used Mono/Apache for running ASP.NET web applications. The only problem is that they didn’t support SQL Server, but instead, they provided free MySQL hosting (which was not surprising).

I started with some initial porting from SQL Server to MySQL. The first milestone that I want to make sure is that LINQ to Entity for MySQL works on the server. After writing a simple proof-of-concept application and published through front page extension, I found that System.Data.Entity wasn’t supported by Mono. This is out of the development plan on the Mono webpage. Thus, I’d need to explore other options such as LINQ to nHibernate with MySQL.

, , ,

2 Comments

Escape and Unescape functions for Javascript and ASP.NET

I’ve been working on a chatroom application that requires some AJAX calls to submit messages from user input. Usually, when you want to pass string parameters into the web service, you may do something like this:

escapeDemo_002

This jQuery script calls an asp.net web service method called submitMessage with two parameters sessionIdStr and messageText. The source of parameter messageText is from a input textbox. Since the user may enter any characters (including special characters), and if they have a single quote (‘) in their input, the above statement will break. To resolve this problem, we can simply make use of the escape and unescape functions from javascript.

escapeDemo_003

The escape javascript function simply encode a string to remove all the special characters in order to ensure that messageText parameter is transmitted successfully within the ajax call. For more information about this function, click here.

Now that our messageText paramter can passed successfully to the web service, we may need to do an unscape operation within the web service method to revert it back to the original input. Microsoft has provided us with a very handy library in namescape Microsoft.JScript.GlobalObject.

escapeDemo_004

Now we have the messageText parameter revert back to the original message. We may do our handling code accordingly.

Note that both Javascript and Micorosft.JScript.GlobalObject has escape and unscape operations, you may use the combination in the reverse way (within web service response).

This is it for this short tutorial. Recently, I’ve been dealing with the .NET System.Datetime and Javascript Date conversion, when I have sometime, I’ll share my experience with you here!

, , , , , ,

No Comments