One of the most amazing features of ASP.NET MVC is its powerful routing engine that let you define clear URLs for your web application. Today I want to share a very simple and short tip with you to handle non-English URLs in your ActionLink methods.

Let’s start with an example; in a blog engine we have two routes as follows:

routes.MapRoute(
                "ShowPost",
                "read/{url}",
                new { controller = "Post", action = "Show" }
            );
 
routes.MapRoute(
                "EditPost",
                "edit/{url}",
                new { controller = "Post", action = "Edit" }
            );

and you decide to show a Persian title in a URL as follows: /blog/read/این-یک-عنوان-است

Everything is fine till now but if you want to put an ActionLink in your view to redirect user to edit page in this way:

<%= Html.ActionLink("Edit", "Edit", new { url = Model.Url }) %>

You will be redirected to an ugly encoded URL like this /edit/%D8%AA%D8%B3%D8%AA instead of /blog/edit/این-یک-عنوان-است

Here’s the simple trick to overcome this:

<%= HttpUtility.UrlDecode(Html.ActionLink("Edit", "Edit", new { url = Model.Url })) %>

That’s it!

kick it on DotNetKicks.com Shout it


 
Categories: ASP.NET MVC | i18n | Web Development

April 20, 2009
@ 11:13 AM

It's about one month that ScottGu and his team have released ASP.NET MVC 1.0 but still there aren’t numerous books on this topic available in the market. As I know by far, these titles are available to purchase: ASP.NET MVC Framework Preview and ASP.NET MVC 1.0 Quickly. I know there are many articles and blog posts containing valuable information and tutorials to start learning ASP.NET MVC but many developers prefer to read books because they are better structured to learn something. From the earlier previews, authors that had been starting to write books on this topic offered some sample chapters to introduce them to the community (and they are still doing) so I decided to list all (or at least most) of them here for a quick access. My list contains both PDF sample chapters as well as link to some authors’ blog posts which contain draft unedited versions of their books:

As Wrox has announced, Professional ASP.NET MVC 1.0 is to be published in April and we’re close to see what ASP.NET team have done as a book for ASP.NET MVC developers!

kick it on DotNetKicks.com Shout it


 
Categories: ASP.NET MVC | Book Review | Download | eBooks | Freebies

A few days ago I had a chance to see a tweet from Wrox inviting users to participate in a private review access to ASP.NET MVC 1.0 Website Programming: Problem - Design – Solution and fortunately I was among those 10 lucky guys who  gained access to the first eight chapters of the book (it sounds good that authors are starting to offer sample chapters in private or public preview forms like what ScottGu has done by publishing the first chapter of Professional ASP.NET MVC 1.0). Meanwhile I don’t want to write a classic review post about this book because the book is not yet officially published and also I don’t have access to other chapters. I just want to thank Wrox guys and book authors to do this and I’m sure such movements will increase Wrox books quality.

What I want to talk about in this blog post is a very good ‘How to’ section in chapter 2 of this book: ‘How do I choose between MVC and Web Forms’. It has been a common question among all ASP.NET developers since the first preview releases of ASP.NET MVC and many guys in the community have wrote posts and articles about it. The last discussion I remember on this topic was Rachel Appel’s session at MIX ‘09 titled ‘Choosing between ASP.NET Web Forms and MVC’ (you can also download a high-res video here) that was very useful. After reading the book preview chapters I found a very good and practical way to rank your real need in the book and it was a worksheet to help you make the right decision for a project; as we read in the book:

After publishing this post I found out that author has already posted about this on his own website. So to respect his and Wrox Press rights I removed the mentioned section from chapter 2 of the book and you can read about it at http://www.coderjournal.com/2008/12/introducing-aspnet-mvc-part-2-aspnet-mvc-vs-webforms/ 


P.S.: I want to thank Nick Berardi, Al Katawazi and Marco Bellinaso, that are the book authors, for their cool book :-)

P.S. (2): As I found out (after publishing this post, and I swear I haven’t ever seen that) there is an original post about this by Nick Berardi and so I reference it here and I may remove the whole post content except this link if Nick or Wrox request (I did it) that but it seems that someone likes to argue about this more than what the owners of the book should do. Dear Lee! I don’t need to get impression as you said; I just wanted to spread a good word and thank them but you introduced me as a community killer and I’m so sorry for you!

kick it on DotNetKicks.com


 
Categories: ASP.NET | ASP.NET MVC | Book Review

A few months ago I found an amazing Web 2.0 free service called Chi.mp. As Chi.mp guys have stated in their about section, main goal of this service is centralizing online identity consists of content (blog entries, photos, videos, tweets, etc.) and your contacts and friends in one place. Once you sign up with them you receive a dedicated domain name with .mp extension (.mp is the ccTLD for the U.S. Commonwealth of the Northern Marianas Islands (CNMI); for more information take a look at get.mp website) and then you can setup and configure your current social activities into your domain.mp. Many services like Twitter, Flickr, YouTube, Facebook, RSS Feeds, etc. are supported now. Your visitors then can see your latest updates on social sites in one place and also can see your contact information based on your public/private settings.

Another amazing feature that Chi.mp offers to its users is OpenID! Yes! Chi.mp is an OpenID provider and once you sign up with them, your own domain name is an OpenID address as well. This is great because you can use a very pretty, short and easy to remember address as your OpenID instead of those ugly URLs provided by Google, Yahoo and other OpenID service providers!

You can also define an email address on your own .mp domain name and forward it to your favorite email address. Mine is i@mahdi.mp now!

Chi.mp is a ‘by invites only’ service at present and you should request current .mp owners to send you an invite (if any left!) or being in a waiting list by adding your information here. [Sorry! I don’t have any invites at present!]

Since Chi.mp is still in beta stage there are many many features that can be added and more enhancements that can be applied to this service and I’m sure it can be one of the most favorite services of 2009 among Web 2.0 geeks.

By the way, my Chi.mp account can be found at http://mahdi.mp ;-)


 
Categories: Freebies | Personal | Web 2.0

January 1, 2009
@ 07:52 PM

Happy New Year 2009!I would like to congratulate the new year of 2009 to my readers all around the world who celebrate these days as new year holidays. I wish a coming year full of happiness and prosperity for you both in your personal life and also your job and technical stuff.

Unfortunately 2008 was not a very good and productive year for me despite I didn’t had any major problem and I was happy with my wife, my little daughter and my good friends but I expected better life and work opportunities. Anyway we passed 2008 and it’s time to take a fresh breath!

In my opinion it’s not late yet while we are alive! We’ve started a new year and I hope I would gain my goals in this new year.

I’m going to learn something new in 2009 that one of most important of them is ASP.NET MVC. Microsoft new web programming framework will rock MSFT web dev community in the coming months and I should learn more and more. So I’ve already pre-ordered a copy of Professional ASP.NET MVC 1.0 and I expect it within the March 2009. WCF may be the next candidate. We may also think of relocating our office but we (me and my friends at Digital Persia Corp.) have not yet decided.

I hope I would expand my activities in the .NET community as well. A site dedicated to ASP.NET MVC is one of my main projects (We are at early stage and I will write a post about it in near future; hopingly after RC release). This site will be founded by me and one of my dear friends but I don’t mention his name now because I guess he doesn’t yet like to announce his participation.

As I write more I remember more overdue stuff to put on schedule in 2009; one of them is migrating my blog from dasBlog to something else (BlogEngine.NET or Graffiti). What do you suggest?!

Anyway, I try to make a better 2009 because nobody else can! Let’s remember God and try to help each other more.


 
Categories: Life | Personal | SharpLife.NET

Recently Microsoft released a beta edition of Anti-XSS library V3.0. Here’s a list of some new features which were added in this release:

  • An expanded white list that supports more languages
  • Performance improvements
  • Performance data sheets (in the online help)
  • Support for Shift_JIS encoding for mobile browsers
  • A sample application
  • Security Runtime Engine (SRE) HTTP module

Also as you can read on Microsoft Connected Information Security Group blog they have also released a CTP version of CAT.NET (Microsoft Code Analysis Tool .NET) which is a managed code static analysis tool for finding security vulnerabilities such as Cross Site Scripting - SQL Injection - Process Command Injection - File Canonicalization - Exception Information, etc.

Downloads:

kick it on DotNetKicks.com


 
Categories: .NET General | ASP.NET | Download | Microsoft | Security

McAfee, the famous security products vendor, offers a %100 discount on McAfee Virus Scan Plus 2009 + 1 year free subscription (a $40 value). To receive your own free license just go here and enter VSPPROMOCF as coupon code and click on checkout; now you have a $0 shopping card!

Offer is valid through December 31, 2008. You can download your copy for Windows 2000, Windows XP and Windows Vista.

+ [via Labnol]

+ It seems that free Anti Virus offers is going to be expanded after Microsoft announced free Anti Virus offer in near future!


 
Categories: Download | Freebies | Security | Software

December 7, 2008
@ 07:24 PM

Once upon a time there were only limited everyday tasks for geeks such as checking emails and in recent years, checking feeds. After Web 2.0 revolution these tasks number has been dramatically increased. Nowadays you have to check your Twitter, Friendfeed accounts several times a day (and for someone several times an hour), manage multiple messengers like Yahoo! WLM, GTalk, Skype, etc., posting various resources to sites like Delicious and Digg, and many other hidden tasks which can consume your time and energy everyday. In this situation busy persons like me would fall in this trap and waste a huge amount of time everyday. What can we do? In recent weeks I tried to manage such stuff and ‘clean up my digital life’! It could help me a lot and so this idea came to my mind to share these experiences with you too. Here’s a list of suggestions and tips to mineralize your social web activities such that you lose the least:

- Follow less people on micro blogging systems: I saw some people who follow thousand of peoples on sites like Twitter and Jaiku. Are all of them your friends or people who you may be interested in their words? Do you read all of their tweets everyday? Of course not; so reduce your following list number. Follow only your real friends, prominent community guys and valuable news/resource twitters. Keep this number under 100.

- Use desktop clients for Twitter and Friendfeed: If you’re a fan of Twitter or Friendfeed, try to use a good desktop client to check updates and posts your own updates. Checking for updates via browser is confusing. My favorite client for Twitter is TweetDeck but unfortunately it doesn’t yet support Friendfeed; to check both Twitter and Friendfeed in one client you can use Twhirl.

- Clean up your messenger friends list: You may have dozens of friends in your messengers who are not real friends and you’ve added them once or they’ve did and you accepted and added them back. Most of them are only like spammers to you and you may receive many offline and online messages from them everyday (and most of these messages are kind of ‘Send to All’). I suggest you organize and clean up your friends list and keep only those whom you chat to frequently. Remove all others. There is another point, If you want to no longer receive messages from them you’ve to ignore and mark them as spammer and this decision depend on you. My personal solution was creating another messenger ID and adding all my required friends to that account again. I’m satisfied with this solution and my list is so clean now! [Tip: There are many short IDs available on ymail.com (for Yahoo!) and live.com (for WLM). Try it!]

- Use less messengers at a time: Many of us have multiple IM accounts such as Yahoo!, Live, GTalk, Skype, AIM, etc. but is it necessary to put all of them in startup and being singed in everywhere? I guess not; Reduce the number of your online messengers to two at most. You can have other messengers installed but use them only when you need.

- Clean up your feed reader: How many feeds do you have in your feed reader? How many of them are really important and interesting and you read them? I guess this ratio is 100/50; I mean if you have 100 feeds in your reader, only 50 of them may be useful and important and other 50 feeds may be ignorable. It’s my own experience before organizing my feeds, I was marking many of my feeds as read prior to read their content. You learn which feeds are your favorites after about 15 days of adding them to your reader. So if you feel you don’t use a particular feed’s content, remove it and let yourself focus on other important titles.

- Use bookmarklets and extensions to bookmark links: If you’re a fan of bookmarking sites like Del.icio.us or Digg, you can use Firefox extensions, toolbars or bookmarklets to easily post links to your account.

- Waste less time to check emails: I have both Web based and POP3/IMAP email accounts and to check them all, I had to open Outlook and a browser tab several times a day and perform a repeating send/receive action to see if there is new mails. This process wastes about 5 minutes each time and if I repeat this 6 times per day I lose half an hour for nothing! What did I do to solve this problem?! My favorite sidebar is Yahoo! Widgets; and my most favorite widget is Informer. There are a lot of works you can do with Informer but here, I want to talk about email checker sensor. You can add as many email accounts as you want including Yahoo!, Gmail, any POP3 or IMAP account and this widget which sits above your task bar checks for new emails in selected period of time and shows the number of new emails; if you hover it you can see latest emails subjects as well and if you like to see it you would click on account name to open browser or favorite email client. Yep! You save your time ;-)

- Keep your desktop clean: A desktop full of icons consumes more memory and you get puzzled soon with all these icons. Only keep necessary shortcuts on your desktop and let your eyes enjoy a beautiful desktop wallpaper!

 

These were my own experiences and you can find your own tips to easily manage a better digital life, so share them with me ;-)

kick it on DotNetKicks.com


 
Categories: General | Life | Personal | Web 2.0