Welcome to weblogs.com.pk Sign in | Join | Help

ASP.NET Applications

Discuss and share about ASP.NET Development
Google Malware Warnings Right Now ... OR .....

UPDATE: A data entry glitch by a Google employee led to this. Read about it here: 'Human error' shuts down  Google.

Is something up with Google? Every single search that I do shows a malware warning (even sites like microsoft.com). Is there something wrong, or something's up with my computer.

Google Malware Warning on every search result 

 

ASP .NET Client Callbacks

And, here are the links to the remaining three parts of the video. Seriously, time limit on YouTube videos should realistically be around 15-20 mts.

Part 2 of 4 | Part 3 of 4 | Part 4 of 4

 

Converting non-English videos into English Using .NET Framework

In a bid to make my videos more accessible to a global audience, I came with an idea to use System.Speech classes to convert the audio tracks on my videos into English using Speech Synthesis provided by the .NET Framework.

Here is some sample code in a Windows Forms Application. Code is written in the Button click event handler. Requires imports statement for System.Speech and System.Speech.Synthesis.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim mySpeech As New SpeechSynthesizer()
        mySpeech.SelectVoice("Microsoft Anna")
        mySpeech.Volume = 100

        Dim myList As New List(Of String)
        myList.Add("Today, we learn how to convert non-English videos into English using .NET Speech Classes")
        myList.Add("If your video is not in English, and, you would like to make it accessible to a global audience in the English language, then, ")
        myList.Add("we can use a trick to convert the videos into English.")
        myList.Add("We will make use of System.Speech namespace in this program and see how this all ties up.")

        mySpeech.SetOutputToWaveFile("d:\6.wav")

        For Each myItem As String In myList
            mySpeech.Speak(myItem)
        Next

        mySpeech.SetOutputToDefaultAudioDevice()

        mySpeech.Speak("File Saved")
    End Sub 

Though still haven't tried it, but importing the audio into Windows Movie Maker and then merging it with my existing videos should work and create a new movie file with an English track.

I have still to learn more about the Speech API and to make the voice sound more human (though, the Microsoft Anna voice is rather brilliant, I must admit). It is only on certain occassions that the voice falls short of the intended mood+pitch - which I think could be addressed with some of the other classes in the Speech API.

MSDN Hackable URL's

Here is a neat trick that always comes in handy when looking for a quick reference on classes and their members in .NET. MSDN URL's are hackable; they can simply be called as follows:

http://msdn.microsoft.com/en-us/library/system.net.networkinformation.networkinterface.getisnetworkavailable.aspx

The above returns the page with information about the GetIsNetworkAvailable method in Networkinterface class of System.Net.Networkinformation namespace.

So, for example, you need a reference on ASP. NET Membership class (System.Web.Security). Here is the URL:

http://msdn.microsoft.com/en-us/library/system.web.security.membership.aspx.

So, if you know of a class and/or its members, reference is just a click away.

Httpmodules: App Level IP Address Filtering
App Level IP Address Filtering: HttpModules

How to work with httpmodules. I tried to embed a video but it does not get rendered on the blog post. Neither does this version of CS have add media option. Can someone let me know how to embed youtube videos here? Thanks!

Finally, here are the links to my recent video tutorials on httpmodules and how to work with application level IP address filtering.

Part 1: http://ca.youtube.com/watch?v=ytMSI1-aJfM&fmt=18

Part 2: http://ca.youtube.com/watch?v=G_4__HdG4PA&fmt=18

Part 3: http://ca.youtube.com/watch?v=AOIUdCLBP9I&fmt=18

280slides.com - Web Presentation App

Interesting Web App to create presentations. The whole UI feels like a desktop environment. It is coded in a language called Objective-J.

http://www.280slides.com

Google Search RSS Feeds

Here is my attempt to transform Google Search Results into a RSS feed. This functionality is missing from Google. Test it out and provide some feedback. I have published the feed as a web service at

http://www.ecubicle.net/gsearch_rss.asmx

There is a single function called GetSearchResults with the following signature

GetSearchResults(byval searchPage As string, byval gQuery As String, byval numOfResults As String)

  • searchPage provides the google search page that runs in multiples of 10 with 10 results each page (default on Google). The value for first page is 0
  • gQuery is google query. You can use any set of Google operators here to tune the query
  • numOfResults is the number of results to return per page. Default is 15.

The returned XML is RSS 2.0 compliant. As such, any feed reader can also read the returned XML document.

 

Using in a Feed Reader

To call this in a feedreader, here is the GET syntax for the web service

http://www.ecubicle.net/gsearch_rss.asmx/GetSearchResults?searchPage=0&gQuery=tutorial+asp+net&numOfResults=15

In the above, replace the parameter values shown in red with the your query values.

Extension Methods in VB.NET

Extension methods allow developers to add functionality to the existing .NET types without recompiling the source, or extending (deriving from the type) the type. For certain types, such as String, these cannot be extended because they are declared as Notinheritable (Sealed). For such scenarios, create an extension method to add custom functionality. Here's an example:

Imports Microsoft.VisualBasic
Imports System.Runtime.CompilerServices
Public Module Module1 <Extension()> _
Public Function ValidateEmailAddress(ByVal emailAddress As String) As Boolean
Dim emailRegEx As New Regex("\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*")
If emailRegEx.IsMatch(emailAddress) Then
Return True
Else
Return False
End If
End Function
End Module
 
The requirements to create an extension method in VB.NET are as follows
 
i) Import System.Runtime.CompilerServices namespace
 
ii) Create a Module
  • Extension methods may only be created in a module
iii) Use the Extension attribute with the method
  • Each extension method must have the Extension() attribute

To use the function defined above, use code like this:
 

Dim s As String = "rafayali@gmail.com"
If s.ValidateEmailAddress() Then
Response.Write("verified")
Else
Response.Write("check the format of email")
End If
LINQ and ADO .NET Data Services Videos

I have published some tutorials on YouTube on LINQ and ADO .NET Data Services. ADO .NET Data Services allow creation of REST based services which is simply a fancy way of serializing data as XML and returning it over HTTP. You can view these tutorials on my YouTube Channel at

http://ca.youtube.com/rafaybinali

 

 

Google Maps KML and LINQ to Display Driving Directions
The important part is to retrieve the KML file (XML based standard) from Google Maps (refer to urlString). Once we have the KML file, we create an XMLDataSource control, retrieve the XmlDocument's InnerXml. After that, we parse the elements to retrieve the directions which are placed in the <name> element under kml/Document/Placemark. 
 
Dim fromAddress As String = Server.HtmlEncode(txtboxSourceAddress.text)
Dim toAddress As String = Server.HtmlEncode(txtboxDestinationAddress.text)
Dim urlString As String = String.Format("http://maps.google.ca/?q=From {0} to {1}&output=kml&view=text", fromAddress, toAddress)
Dim xmlDataSource2 As New XmlDataSource()
xmlDataSource2.DataFile = urlString
Dim xdoc As XDocument = XDocument.Parse(xmlDataSource2.GetXmlDocument().InnerXml)
Dim ns As XNamespace = XNamespace.Get("http://earth.google.com/kml/2.0")
Dim ele = xdoc.Element(ns + "kml").Element(ns + "Document").Elements(ns + "Placemark").Elements(ns + "name")
GridView1.DataSource = ele.Take(ele.Count - 1)
GridView1.DataBind()
 
I have used the XmlDataSource control in this example because this is a code snippet from another project that I worked on. However, we can also use
 
Dim xdoc As XDocument = XDocument.Load(urlString)
 
The above line of code would load the KML file from remote server into xdoc. The remaining code remains same from this step onwards.
 
YouTube Download Web Service: Integrate YouTube Download into your .NET apps FREE

Here is an interesting web service that allows applications to download youtube videos. Applications that require interaction with youtube can obviously use the YouTube API's to provide exhaustive youtube functionality right from their web sites. However, the only API function that is missed is the ability to download from Youtube.

The Youtube web service provides this missing functionality.

The service is located at http://www.ecubicle.net/youtubedownloader.asmx

What the service does is provide the download URL for any video on Youtube. .NET applications can then use any method to access the download URL and download the file. For example, WebClient.DownloadFile() method can be used to download the file directly if the returned URL is passed to DownloadFile.

Very interesting.