BlogEngine.Net's contact form fixed for Hotmail users (well, hacked)

by Patrice 11/11/2008 11:10:06 AM

The other day, my wife decided to make a joke on me and used the contact page on this blog to ask funny questions. Yesterday, she was asking about my blog, how it was going, are people interested, do I receive... emails? hmmm, why is she asking all these questions suddenly? Finally the cat went out the bag... She told me about her joke... but I never received any email. Alright, this could be due to a SMTP configuration problem. But BlogEngine.Net "test" email function worked (this is part of the admin page to test SMTP values)... I then tried the contact form myself and I never received any feedback... I tried again by filling the "from" field using a different email and this time it worked... hmm, okay, the difference between my wife (as with my first test) and my second test is hotmail.com. I can even use the contact form using a fake "from" as bla@blablabla.bla and it will work.

This site is hosted on GoDaddy, my lfdx.com emails are hosted on GMail. It's known that to use GMail POP3 you need to use the port 465. But this port is blocked on GoDaddy servers. The solution is to set the SMTP server to relay-hosting.secureserver.net (GoDaddy server, considering that you already have set your MX records to point to googlemail.com). So, where is hotmail.com blocked? Somewhere within GoDaddy infrastructure I suppose. This is not crucial and I don't have time to investigate with GoDaddy.... Let hack the code then. Quicker and funnier!

Since I have compiled BlogEngine myself, it was easy to "debug" and "patch" the code... I opened contact.aspx.cs page and went to SenEmail() method. That's where I decided to hack the "from" field. Here is how... nothing complex.

I replaced this:

mail.From = new MailAddress(txtEmail.Text, txtName.Text);

to:

string email = txtEmail.Text.ToUpperInvariant();//for the String.Replace method
//Hotmail patch for GoDaddy-Hotmail-GMail issue
if (email.EndsWith("HOTMAIL.COM" ))
    email = email.Replace("HOTMAIL.COM", "_REMOVE_hotmail.com");

mail.From = new MailAddress(email, txtName.Text);

This way, I receive hotmail emails and if I need to do a reply, I just have to delete the _REMOVE_ part.

Unfortunately, I don't like the way I hacked BlogEngine.Net code since the next time I will upgrade BlogEngine.Net, this part will be overwritten. But I don't have time to figure a best way for now.... If anyone has one, you are welcome to share your solution!

Live Messenger API Status Icons

by Patrice 10/13/2008 10:43:21 PM

I just finished working on a small task where I wanted to use Live Messenger API in a web page (this allows the user to contact you using Messenger without having Messenger installed on his machine and having your contact set in it).  A friend of mine just did this for his business web site and I found it very useful. I decided to try it myself.

Since my friend has already done this, he guided me directly where I needed to go to learn about the API. After 10 minutes, it was done.  Basically, you just have to paste this (replace 1111111111111 by your user ID):

<a target="_blank" href="http://settings.messenger.live.com/Conversation/IMMe.aspx?
			invitee=1111111111111@apps.messenger.live.com&mkt=en-US">
    <img style="border-style:none;" src="http://messenger.services.live.com/users/1111111111111@
			apps.messenger.live.com/presenceimage?mkt=en-US" />
</a>

...and it returns this series of icons:

, , etc   ....they are small, just 16x16 and not "clean".

So what can I  do? After investigating, I found that I can get the status by two ways (1111111111111 is your user ID):

1- http://messenger.services.live.com/users/1111111111111@apps.messenger.live.com/presenceimage?mkt=en-US

...that will redirect to the status gif image.

2 - http://messenger.services.live.com/users/1111111111111@apps.messenger.live.com/presence?mkt=en-US

...that will return the status information in JSON format.

One thing I didn't want is use JavaScript. Obviously, if that wouldn't have been the case, JSON would have been the best choice here and easily implemented.

So I had to do the job from the server. I was looking for the easiest way so I just called ".../presenceimage?", using HttpWebRequest and just replaced "live.com" link by my server path... easy!

using (WebResponse response = request.GetResponse())
{
    string msnpath = response.ResponseUri.AbsolutePath;
    localImg += msnpath.Substring(msnpath.LastIndexOf("/") + 1);
}

Note that I don't download the image by calling GetResponseStream.

So by replacing the path, I obviously need to have the replacing image on my server. For that, I Googled a bit and found two set of icons that look much better. MSN Crystal Icons and Messenger Icon Pack... Just use your favorite image editor to resize then and/or change the format.

While I was there, I said "Well, why not a custom control?" To implement this I just rendered the a and img elements in a WebControl ... just few lines... look at the code if you are interested...  In the ASPX, it looks like this:

<lfdx:MSNMessenger uid="8a69c004ce9860b4" cssclass="wt" serverimgpath="images/" runat="server" />
  • uid is the Messenger user Id
  • cssclass class applied to a element
  • serverimgpath is the location of your custom images

Download the project here. Note that I have included the "Messenger Icon Pack" that I have resized to 30x30 gif images.

Nothing complex here just a fun project!

 

Illustrator Live Trace and Live Paint... cool!

by Patrice 9/20/2008 1:57:55 AM

Alright, again, I'm a developer, not a designer... but I like the design related stuffs. See the dumb monkey face on the right side? Well, I just drew it quickly, scanned it in Photoshop and set it up here to replace the default BlogEngine.NET avatar when I started this blog.

Two weeks ago I got Illustrator CS3 (I know, I know, CS4 is coming soon...), so I experimented with it, obviously just the basic stuffs following tutorials.

Last weekend I needed some "original" icons and I didn't have any #%$ inspiration... So I took my pencil and draw things on a piece of paper... "hmm, that looks good!"... So what damn? Am I gonna scan this in Photoshop and try to apply colors...again? I have already tried this many times in the past without success... not even close to be able to use it on a web project.

After browsing Internet on "techniques" on how I could do this, I felt on this Using Adobe Illustrator CS2’s Live Trace tutorial (I didn't even know this was part of CS2)... Well, that seems easy!... the first thing I have tried is to use my own monkey... I got back my old sketch, traced it back a bit darker and scanned it again in Photoshop

Then, following the tutorial and playing with the "Live Trace" properties, I got a nice "vectorialized" monkey... After enabling "Live Paint" and applying two "Live Paint Bucket" on it, I got this

Alright, alright, it's not a "finished" professional image but it just took me few minutes...

Here is another quick sketch I did of a pair of pliers that were lying on the table....

I'm sure designers that read this think that "Live Paint" feature is for amateurs... I give that to you! ha ha ha ha... That's probably like "wizards" or "drag and drop controls" features in Visual Studio... For me, this is like "well, you don't know how it works, so use it... but you won't be able to dig further down in the code because you won't understand a &%*@ thing of what it produces..."

WebBrowser control... Mono/Gecko update

by Patrice 9/8/2008 9:46:19 AM

Since my last update everything run smoothly on the server. I'm a "Microsoft guy" but I always liked to experiment on Linux. Once a year, since college, I get an old machine, format it and re-install the latest Linux version and after everything is done... nothing... ha ha ha ha. ...but this time though, I had another goal in mind... compile my code with Mono and running it on a Linux box! (I know, I could have use Mono on Windows but, hey, what's the fun?)

So last weekend I undusted my machine, boot it up and reformatted it. This time I've installed openSUSE... The installation went smoothly without any issue.  First, I was curious to see if my code would compile at all using Mono... I have been very surprised to see that it did compile.... except the "interop" part where I use the browser obviously.

Hmmm, alright, it's time to try Gecko to produce my browser "screenshots". That was the easy part... there is still a sample code on the web that is dated '04 and does that. Before modifying my existing application, I compiled the sample code and tried it ... no issue here... except one thing: the browser needs to be "visible"... and that is not good.  That's the same issue I got when I tried IHTMLElementRender::DrawToDC version on Windows... I haven't found a way to hide the window and get the image... it only outputs a black image...

Unfortunately, time is precious and that's all I had to give to it...

See you next year Linux!

Graphic design from a novice

by Patrice 8/7/2008 1:12:33 PM

Ok, I'm a developer, not a designer. I like drawing, painting and I've always liked designing small items for my web development like buttons, backgrounds, logos, etc. To do this, I used to use Photoshop. I cannot say I'm a "pro" but I can certainly be efficient with those small tasks.

I have switched to Illustrator six months ago. I really like it. The fact that you can resize the items without loosing quality...Wow! How many times have I cursed about this because I haven't started my "button" the right size and had to resize it from Photoshop with crappy results?... So, six months ago I was trying to create a favicon in Photoshop...aarrggg, I'm sure there is a technique but I haven't found it!!! That's where I discovered Illustrator while reading an article that was talking about it. Obviously, the switch was not easy... I bought two training DVDs I finally managed to convert (convert as in "redoing it from scratch") my latest projects in Illustrator.

I really like prototyping my web layout in Illustrator. At least the rounded boxes keep their corner sizes... Something I'm not good at is to "when to stop" designing (since it's more a hobby then a job with deadlines)... I add and add and delete and add... and then realize that the one I did two hours ago was probably the best one... but I don't have it anymore.

So I have decided to take a copy of my AI file every time I'm satisfied with a design and then keep working on the master file. That works perfectly for me! I also export each copy into PDF. It's easier to present or review the layouts. While I was there, I've develop a small tool using PDFSharp library. It merges all my PDF files into a single file and creates "bookmarks" on the left side panel... Really nice for picking up the best design!

I wonder what the experimented (professional) designers do?

 

Update 1: Someone wrote me that in Acrobat 9.0 Extended, there is a way to create a "portfolio" into your PDF file that gives a really nice "presentation" media...

Update 2: Wow! From the video on Adobe web site, it looks very powerful (even PDF merger included)... I'll take a look with the trial version.

Tropical Storm Bertha... take 2

by Patrice 7/14/2008 9:31:17 PM

I finished working earlier this afternoon and we went to the beach for a walk...  My son was very excited!

My street

 

Horseshoe bay - wife and son

Tropical Storm Bertha...

by Patrice 7/14/2008 9:28:09 AM

Well, the first storm of the season is always exciting... not so much for the wind this time though...

This was yesterday night... At least the rain has arrived this morning (it hasn't rained here for 4 weeks...)

Horseshoe bay

 

Astwood Cove

WebBrowser control... update

by Patrice 7/2/2008 10:08:49 AM

Just to update you on how my web page thumbnails generator (described in my post my WebBrowser experiment ) goes on...

Since this is used on a server, it , as expected, crashed a couple of times per load test... that's not very useful... I brought a little modification to it...  and it didn't crashed since then.... (note that this is not on production servers)

So the first thing I do is that I load the web page using HttpWebRequest and get its stream from HttpWebResponse.GetResponseStream. Once I get the stream I create a new WebBrowser but instead of opening the page from a URL (with WebBrowser.Navigate), I load the stream that I got from HttpWebResponse into my  WebBrowser's DocumentStream property. And that's it! the rest is the same as before! It's even nicer since I just get the WebBrowser.DocumentCompleted  called once... I don't need to look at the URL to see if it's my main page or an embedded Flash stream... and no more about:blank called after it is completed.

So here is my new method that I have added to my ScreenCapturerSTA class:

 

private void CaptureMS(object obj)
{
    m_byteImg = null;
 
    MemoryStream ms = obj as MemoryStream;
    try
    {
        using (WebBrowser webBrowser = new WebBrowser())
        {
            webBrowser.DocumentCompleted += 
                new WebBrowserDocumentCompletedEventHandler(webBrowser_DocumentCompleted);
            webBrowser.Height = 1000;
            webBrowser.Width = 1000;
            webBrowser.ScriptErrorsSuppressed = true;
            webBrowser.ScrollBarsEnabled = false;
            webBrowser.DocumentStream = ms;
            while (!m_done)
            {
                Application.DoEvents();
            }
        }
    }
    catch (Exception ex)
    {
        Trace.WriteLine(ex.ToString());
    }
}

So, just a coincidence? I mean, the WebBrowser still has to load the content...  at least it seems more stable now... 

Next step? hmmm, I'm tempted by a MONO/GECKO experiment...  I might give it a try...

HttpWebRequest.AllowReadStreamBuffering = false... Still buffering up to 4kb!

by Patrice 6/26/2008 6:58:00 AM

So why when you set it to "false" it doesn't seem to take effect?

This wasn't easy to guess... and this property is new in Beta 2 so not so much "discussion" on the web about it. After few hours stolen from my sleep time, I've found that the BeginGetResponse callback parameter will be called only when you'll have at least 4kb "buffered"... (is this "by design"?)...after 4kb of data received, you can receive a single byte at a time if you need to!

Look at my post on Silverlight forum for more details.

 

Update: This problem is specific to IE. It works in Firefox... but I have found another issue with Firefox; if you set a custom header webrequest.Headers["custom"]="custom" , AllowReadStreamBuffering won't work.... no effect... it will wait until the stream is all arrived.

Damn! Expression Blend 2.5 June Preview allow Template editing from Silverlight projects

by Patrice 6/9/2008 7:26:59 AM

In last my post about "Silverlight Project Structure" in Visual Studio, I talked about how Jose Fajardo was defining his project's structure and how it seems being a good approach. One problem, as Jose mentioned, was that "templates" edition weren't supported by VS-Blend combo. The solution was just to create a regular UserControl (so editable in Blend) and copy&paste the content in the app.xaml TemplateControl section (considering a "global" template).

If you got it right-on, that was good but after few copy&paste it became annoying. I was tired of editing my templates manually... manually as in "edit UserControl in Blend, open app.xaml, copy & paste UserControl code into the the TemplateControl section".

So I've started "googling" on "Visual Studio addon"... and it pointed me to the Visual Studio Extensibilty (VSX) web site... I've downloaded the SDK, tried the "wizard" project, modified it here and there, done some tests...

 

I ended up with a nice addon that converts my UserControl to TemplateControl by right-clicking my XAML file. Wow, that was much more effecient then a copy&paste...

 

 

 

 

 

 

 

 

All this to say that I was going to publish in more details my VS addon code and description project but after the last byte of Expression Blend 2.5 June Preview and Silverlight 2 Beta 2 releases, it's now irrelevant...

Powered by BlogEngine.NET 1.3.1.0

LFDX Software Inc.

About the author

P. Lafond Patrice Lafond
(and yes, it's Mr!)
Software Engineer
French Canadian expat in Bermuda for over 7 years.
flag QC  flag BDA

E-mail me Send mail

Calendar

<<  January 2009  >>
MoTuWeThFrSaSu
2930311234
567891011
12131415161718
19202122232425
2627282930311
2345678

View posts in large calendar

Pages

    Recent comments

    Authors

    Disclaimer

    The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

    © Copyright 2009

    Sign in