Clicky

Once again I want to talk about URLs and who doesn’t know that I’m a big fan of friendly, clean and pretty URLs in my applications! When you write an application (for example a blog engine) you have multiple choices to create unique URL for a single post; you can include an integer ID (myblog.com/458) or a GUID instead of integer or the best way, a friendly URL like myblog.com/hey-i-am-a-clean-url. This value should be unique and should not be changed if your blog post title is changed; so we should have a separate column in our database table to store this friendly URL. I wrote a simple JavaScript code that receives your blog post title, clean it from non alphanumeric characters and replaces them with a dash, change all characters to lower case and make it ready to be sent to your business logic handler:

<script type="text/javascript" language="javascript">
    function parseUrl(url) {
        var cleanUrl = (url + " ").replace(/[^a-zA-Z0-9]+/g, "-");
        return cleanUrl.slice(0, cleanUrl.length -1).toLowerCase();
</script>

and this two lines of code to fill URL field automatically as user types the post title (using jQuery:

<script type="text/javascript" language="javascript">
    $(document).ready(function() {
        $("#postTitle").keyup(function() { $("#postUrl").val(parseUrl($("#postTitle").val())) }
        );
    });
</script>

 

This is very useful if you’re building applications using ASP.NET MVC and have control over URLs using routing engine. This is also helpful for WebForms developers who use routing in WebForms or rewrite extension less URLs using IIS7, ISAPI_REWRITE and etc.

Let your URLs be more friendly against search engines ;)

kick it on DotNetKicks.com


 
Categories: ASP.NET | ASP.NET MVC | JavaScript | SEO | Tutorial

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

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

November 23, 2008
@ 01:20 PM

A few years ago, when I had begun learning ASP.NET and Web Development, I found a nice and lovely guy who was very professional at that age. We were both university students (in different universities) then and was studying Mathematics; me, Pure Mathematics and he, Applied Mathematics. Almost every night, we were chatting using poor dialup connections and he was opening new doors of knowledge to me. He was a professional and pioneer developer and coder at age of 20-21.

I’m talking about my dear friend, Soheil Rashidi. But you may ask why I’m talking about this nostalgia?! Soheil had a website dedicated to Persian language developers to provide articles and useful resources for them. We call it iDevCenter (or iDC). About 2-3 years ago Soheil suddenly stopped iDC because of what he calls an ‘Unresponsive Model’. Now I can officially and proudly announce re-launch of one of my most favorite Persian websites in field of coding and development. Yeah iDevCenter.com is back!

New iDevCenter is completely different from what is was 2 years ago. iDevCenter v3.0 is a powerful Link Directory + a nice Wiki. All old iDevCenter members can login to their accounts using the same username and password (except one poor person that only I and Soheil know :-D). All information are categorized using tags and you can easily find relevant information.

If you’re Iranian or know Persian language I invite you to take a deep look at how Soheil rocks on iDevCenter.com!

 

And special message for my dear Soheil: A world of congratulations and sweet dreams for you :-*


 
November 14, 2008
@ 09:50 PM

Thanks to ASP.NET MVC and C# Extension Methods, many developers in the community have been creating very useful HtmlHelper extensions and some of them are sharing their works. Today I find this nice one for Gravatar (via Simone’s tweet) and after reading that post this thought came to my mind to gather such Helpers somewhere so that others can access them easily and quickly. This post will be the first step to gather and share such Helpers (If I feel it can be more useful than what I’m thinking now, I may launch a dedicated website for this purpose!).

At this early stage I put some links without any categorization, but after my list grows up I try to update my list and categorize them.

If you have written a nice HtmlHelper for ASP.NET MVC and want to share it with others please send me a message or a reply to mahdi on twitter. I update this post as soon as I find new Helpers so you can check it frequently. This link is shorter to remember: http://tinyurl.com/mvchelper

 

- MVC HtmlHelper for Gravatar
- Paging HtmlHelper for ASP.NET MVC
- Marquee and GridView HtmlHelpers for ASP.NET MVC
- ReCAPTCHA HtmlHelper (and also a solution to use ReCAPTCHA in ASP.NET MVC)
- ASP.Net MVC Extension method to create a Security Aware Html.ActionLink
- CheckboxList Helper


If you like to promote my list please kick it on DotNetKicks.com ;-)
 
Categories: ASP.NET | ASP.NET MVC | Download | Web Development

We are getting closer to official release of Microsoft ASP.NET MVC. There are couple of tutorials and videos to get started with this new approach to enterprise web applications development. I found an eight part series of tutorial (in both C# and VB) on ASP.NET Website; good news is that all of these tutorial parts are available in PDF format too. I downloaded all of them and compress them in a single .rar file.

You can download it at http://www.sharplife.net/Files/ASPNETMVCTutorialPDFVersion.rar (approx. 1.7 MB).

 

Enjoy ;-)


 
Categories: .NET General | ASP.NET | ASP.NET MVC | C# | Download | Microsoft | Tutorial | Web Development

It’s so easy to use powerful ASP.NET Membership, Role and Profile provider in a Windows or Console application. Only one key point remains here; you should add an app.config file to your Console or Windows application and include these nodes in that:

<?xml version='1.0' encoding='utf-8'?>
<configuration>
    <connectionStrings>
        <add name="SQLConnString" connectionString="SERVER=(local);DATABASE=SampleApp;UID=sa;PWD=123"/>
    </connectionStrings>
    <system.web>

        <membership defaultProvider="SampleAppMembershipProvider">
            <providers>
                <add name="SampleAppMembershipProvider"
                     connectionStringName="SQLConnString"
                      applicationName="SampleAppMembership"
                      enablePasswordReset="true"
                      enablePasswordRetrieval="false"
                      passwordFormat="Hashed"
                      maxInvalidPasswordAttempts="100"
                      minRequiredPasswordLength="5"
                      minRequiredNonalphanumericCharacters="0"
                      requiresQuestionAndAnswer="false"
                      requiresUniqueEmail="true"
                      passwordAttemptWindow="5"
                      passwordStrengthRegularExpression=""
                      type="System.Web.Security.SqlMembershipProvider" />
            </providers>
        </membership>

        <profile defaultProvider="SampleAppProfileProvider">
            <providers>
                <add name="SampleAppProfileProvider"
                type="System.Web.Profile.SqlProfileProvider"
                connectionStringName="SQLConnString"/>
            </providers>
            <properties>
                <add name="FirstName" type="System.String" />
                <add name="LastName" type="System.String" />
                <add name="Email" type="System.String" />
                <add name="Website" type="System.String" />
                <add name="Address" type="System.String" />
                <add name="Note" type="System.String" />
                <add name="Phone" type="System.String" />
                <add name="Fax" type="System.String" />
                <add name="Feature" type="System.Int32" />
            </properties>
        </profile>

        <roleManager enabled="true" cacheRolesInCookie="true" defaultProvider="SampleAppSqlRoleProvider" 
cookieName=".ASPXSampleAppROLES" cookiePath="/" cookieTimeout="30" cookieRequireSSL="false"
cookieSlidingExpiration="true" createPersistentCookie="false" cookieProtection="All"> <providers> <clear/> <add name="SampleAppSqlRoleProvider" type="System.Web.Security.SqlRoleProvider,
System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"

connectionStringName="SQLConnString" applicationName="SampleAppRoles"/> </providers> </roleManager> </system.web> </configuration>

 
Categories: .NET General | ASP.NET | Security

October 3, 2007
@ 02:07 PM
Omar Al Zabir has recently listed 10 cool articles about ASP.NET, AJAX, ... which he has published this year. From my personal view these articles are interesting:


 
Categories: .NET General | AJAX | ASP.NET | Security | Web | Web 2.0 | Web Development

October 1, 2007
@ 01:54 PM
BlogEngine.NET 1.2 released. As you may know it's a free blog tool written in C# and ASP.NET 2.0 and they added many features to this release which you can see here.

In this release BlogEngine supports 26 language packages including Persian language which I had translated its resources for them.

Although, I don't use BlogEngine at present (and I'm using dasBlog), I'm thinking about migration to BlogEngine because of more features. In this version BlogEngline also supports BlogML for import/export (Thanks Keyvan!).

More on BlogEngline.NET: Download Latest Release | Documents | Hosters that offer BlogEngine.NET | Complete Features List | Some Videos.


 
Categories: .NET General | ASP.NET | Download

It's a few months I have been using UrlRewriting.NET component for my Url Rewriting needs in ASP.NET 2.0. Since it's free and open source and covers many features that I need, it was a good choice for my projects. The big problem with this (and also other available components) is that it can't rewrite fake directories. For example if you have a url like http://myurl.com/products/productcategory.aspx?name=Phone and want to rewrite it to something like http://myurl.com/products/Phone/ you must have a folder named Phone in products folder containing a blank Default.aspx file inside it or in another way map all requests to ASP.NET engine in IIS. Both ways (especially second) are annoying and waste resources.

Because I'm working on a project that needs to rewrite fake URLs and also server resource management is so important in this project I searched for other solutions today and I reached UrlRewiter.NET; but unfortunately this one doesn't support fake URL rewriting as well as previous ones. [There are some tricks to handle fake directories like using customErrors default error page and etc. which you can find on CodeProject.com]. So it is not a good solution for me too. So I searched again and I reached this. It seems that IIS 7.0 new structure lets developers do this. In fact just by adding a few lines to Web.Config you can use your current module to Rewrite all URLs (See this post).

It's a good news but IIS 7.0 is still in Beta and many servers don't support it. Should we wait until Windows Server 2008 to use IIS 7.0?

It's a big question for me that while PHP developers are using this simple feature since a few years ago, why Microsoft don't offer a solution before IIS 7.0 official release.

UPDATE 1: Looking for IIS 6.0 Solutions? See this.
UPDATE 2: Wyatt Barnett has commented on this post and introduced an article written by himself which explains some tricks to make IIS 6.0 Play With UrlRewriting. See it.



 
Categories: .NET General | ASP.NET | Web Development

September 17, 2007
@ 04:44 PM
Today I found an article on ASP.NET official website introducing a custom control to show weather on your website.

Milan Negovan has talked about his control and features in this article. I know it's two easy to write some lines of code to use a customized RSS feed from Yahoo! Weather (RSS example for Tehran current weather) or other websites and display it in an appropriate format in our websites, but as a ready-to-use tool you can just download this control and drop it in your client projects as an extra feature! Before download you can see a live demo here.

For those who want to challenge more with technical issues: This article describes how to use NOAA Weather WebService to show a customized look weather report.


 
Categories: .NET General | ASP.NET | Download | Web Services

September 16, 2007
@ 04:38 PM
asp.netPRO Magazine recently published 3 latest issues in PDF format as a free download. You can download July, August and September issues here.


 
Categories: .NET General | ASP.NET | Download

August 26, 2007
@ 03:35 PM
Scott Hanselman, like past years, introduced a 2007 list of developer and power users tools for Windows. If you are familiar with his cool lists you can enjoy his fresh 2007 version of it and if you didn't hear anything about his list before its time to take a look at it.

In addition to those tools I've ever been using, I downloaded these tools in my first look at list and I will read list exactly later!: Query Express, CollectionGen, Code Style Enforcer, Microsoft BPA, Resource Refactor.

Thanks Scott, you are an angel!


 
Categories: .NET General | ASP.NET | Download | Software | Web Development | Tools

May 3, 2006
@ 04:12 PM
Microsoft released beta 1.1 version of CSS friendly ASP.NET 2.0 control adapters Beta 1.1. This is a free tool let you force your server side controls render html output as you like based on CSS technology. As is read on its web site:

"ASP.NET is a great technology for building web sites but it would be even better if it rendered different HTML. For example, the Menu control makes it simple to add a menu to a web site but it would be better if it didn't create <table> tags and was easier to style using CSS. Happily, it's easy to "teach" the Menu control how to generate the kind of HTML that you prefer. Indeed, you can modify any ASP.NET control so it produces better HTML.

The key is to use something that may be new to you: control adapters. These are little chunks of logic that you add to your web site to effectively "teach" an ASP.NET control how to render better HTML."

You can download it for ASP.NET 2.0 here. Also you can find a complete guide and some live examples here.


 
Categories: ASP.NET | Download | Microsoft | Web Development

Keyvan started to localize Community Server for Persian language and some other Iranian .NET developers joined him so far. They have registered CommunityServer.ir domain name for this project and this web site is a bit active now and will be expanded in the upcoming days.

Read more about it on Keyvan's post. As I know this project is sponsored by DataNet Company.

I may join them if I can.

UPDATE: I joined the team!


 
Categories: ASP.NET | Community Server Persian | i18n | Iran

March 1, 2006
@ 01:49 PM
Microsoft released Anti-Cross Site Scripting (XSS) Library V1.0 for .NET framework [Details]

I think after SQL Injection, XSS is the second vulnerability which many web sites are infected to and so this tool can help (and awake!) many developers control this danger in their codes.

As said on download page of this library, current downloadable package only contains .NET 2.0 binaries and 1.x versions are due to release in future (Bad news :(( I still have to use 1.x version in some projects).

More information about XSS can be found here.

UPDATE: Library updated! Now it supports both .NET 2.0 and 1.x.


 
Categories: ASP.NET | Download | Microsoft | Security | Web Development

February 28, 2006
@ 01:43 PM
It's more than 1 year that I'm using URL rewriting in my web application projects to make pages adresses more friendly. Before ASP.NET 2.0 release and its URL Mapping feature, web developers had to write their own Http Handlers to perform a complete URL rewriting solution. Scott Mitchell had written a good HttpHandler for URL rewriting in ASP.NET 1.x which published on MSDN as a technical article.

For its time, this tool was good enough because it let developers use regular expression to rewrite URLs. One major problem that developers may face while using this tool is "Not Available Folders" rewrite rules. Imagine you want to rewrite a path like this: ~/News/2005/ to ~/News/Default.aspx?Year=2005. It is a good idea to let visitors hack your URLs. But if you don't have a real 2005 folder and a default.aspx file inside it, IIS will return a 404 error page. In such cases we have two solutions: 1- Make a dummy folder for such URLs. 2- Map all incoming requests to ASP.NET engine. It's clear that first solution is not suitable because you should make a new folder on the fly for a record that is added in 2006! And also the second is not a good idea because we should handle all extensions manually. As Scott said on his blog (and on MSDN article), .Text (and Community Server I guess) use a solution similar to our second option but unfortunately I didn't check them so far.

It's my story these days!! If you faced this problem too and have solutions please discuss on it in the comments. (Specially, if you have worked on .Text or CS source codes you may know more about their solutions. So as Soheil says on iDevCenter "Share Your Knowledge" !!!)


UPDATE [3/2/2006]: There is another solution for those who have access to web server. IISMods.com offers an open-source free ISAPI filter for IIS that let you perform URL Rewriting at the web server level. But this solution is not suitable for shared server hosting packages. So I won't use it!


 
Categories: ASP.NET | Web Development

February 21, 2006
@ 01:46 PM
Brian Goldfarb has collected a list of must see "How Do I" video series for ASP.NET 2.0. (Total download size: 198 MB)

 
Categories: ASP.NET | C# | Download | Microsoft | Web Development

February 21, 2006
@ 01:04 PM
MSDN Magazine Special Issue: Visual Studio 2005 Guided Tour.

Download: PDF (21.1 MB) | CHM | Code


 
Categories: ASP.NET | Download | Microsoft | Web Development | C#

February 14, 2006
@ 01:24 PM
bdasamppet401.jpgMicrosoft released PetShop 4.0. As you may know, PetShop is a web application designed to show the best practices for building enterprise, n-tier web solutions using Microsoft .NET technology. The previous version (PetShop 3.0) was a major different release because Microsoft team intoruced a model for PetShop that both SQL Server 2000 and Oracle databases were supported.

In this new version PetShop uses Microsoft .NET Framework 2.0, Microsoft SQL Server 2005 and Oracle 10g Database.

It's a few months that I am using PetShop coding and project model in my own web applications and I think that this model gives all web developers a better feel to develop their projects.

As you can read here, PetShop 4.0 is a good practice for those who want to migrate from ASP.NET 1.x to 2.0 and want to keep their coding style as modern as possible.

If you used PetShop 3.0 before and want to migrate your .NET Framework I suggest you download it right now!

Microsoft PetShop 4.0: Information | Download


 
Categories: ASP.NET | Download | Microsoft

February 6, 2006
@ 02:09 PM
Recently, using Ajax has been dramatically increased among web developers. After Google started its free email service called GMail and used Ajax in it, this technology became more popular and many developers and companies tried to build tools and frameworks for various server side technologies to be able to use Ajax benefits more easily.

From my personal view, Ajax will give your visitors a better surf and they will not bother from multiple refreshes for a single task. I have tested and used Ajax.NET Pro in my recent projects. This framework was written in C# by Michael Schwarz. I think that this framework is powerful and easy to use and implement.
Michael has a personal blog in which he writes about his open source framework. He has also created a group at Google for Ajax.NET Pro.

Two different versions of Ajax.NET Pro are available for ASP.NET 1.x and 2.0.

If you want to know more about other Ajax tools for ASP.NET take a glance at this comparison.

I'm so glad to see that many Iranian developers are using Ajax in their web sites. Even if you use Ajax in a small part of you web site it is admirable. For example quick vote and tell a friend sections at ketabeavval.ir that has been programmed by my dear friend Mohammadreza Taheri.

I have shown some simple usages of Ajax in razmpa.com. If you are an ASP.NET developer and have used Ajax in your projects please send their URLs and I will put them in an update in this post.


 
Categories: AJAX | ASP.NET

February 6, 2006
@ 12:43 PM

Today I have 2 useful free components for ASP.NET 2.0 (and one of them for 1.x as well) to introduce:
  • Code Highligher for ASP.NET 2.0 (Also compatible with .NET Framework v.1.x)
    This component is a source code syntax highlighting tool that can help you make your source codes more readable for your visitors. This component supports C#, CSS, HTML, INI files, Java, JScript, Perl, PHP, Python, SQL, VB.NET, VBScript, and XML and ... It's FREE!
    Home | Sample | Download
  • Flash Control for ASP.NET 2.0
    This component will help you add Macromedia Flash files (with .swf extension) to your web pages using a server side control. You will have full VS 2005 Designer support. The generated code validates XHTML 1.0 strict. You can download and use this control in your projects for free but also source code is available for 199 USD.
    Home | Features | Download
    [UPDATE]: Looking for a similar control for ASP.NET 1.x? Try AIxtend AI Flash'In.

A very strong of marketing is the email marketing and it is growing because of the availability of free web hosting. These hosting services also offer free domain names. Another most famous tool of internet marketing is ppc or pay per click.


 
Categories: ASP.NET | Download

February 4, 2006
@ 03:43 PM
I recently wrote a post about i18n in ASP.NET. Today while I was searching for some better articles about this issue I found Microsoft Middle East MSDN site. This web site is built to help middle eastern developers which their native language is Arabic. Since Persian language, like Arabic, is a right-to-left (RTL) language I think many articles and resources on this web site can help Persian developers build more internationalized windows and web applications. Don't miss it!

UPDATE: Dr. International blog and Microsoft Global Dev. are also interesting :D


 
Categories: ASP.NET | Microsoft | i18n

Code Project is one of my favorite web sites on the internet. I think that the level of articles and the freshness of news which are published on this web site is so much better than other web sites.
Code Project holds an online poll every week and announce its results. The questions that are asked in these polls and the answers sometimes are so funny and sometimes so usefull and technical.

This week question was "Where do you get your IT news?" and the answers:

Option Votes %
Online news sites 528 73.8
RSS feeds 219 30.6
Email newsletters 250 35.0
Podcasts 24 3.4
Webcasts 45 6.3
Blogs 181 25.3
Internet radio 12 1.7
Discussion boards 164 22.9
Responses 715

Two things are interesting to me in this result. First: RSS feeds are still in the 3rd place after Web Sites and Newsletters, and second: Blogs are in the 4th place. If you compare this situation with our country (Iran) results, I think that Blogs can be at the 1st or 2nd place but yet there is no favor in RSS Reader softwares and web sites among Iranian non-professional users.

If we deeply look at these results we find out that most Code Project users are professional web users and developers that should be interested in RSS readers and Blogs; but in real world we see another result! What do you think...?

...

These days I'm busy with a web application project which should be shipped in two Persian and English languages. In this project I decided to build a real multi-lingual web site which can be easily extended to other languages in future. I had read many articles about internationalization in ASP.NET before but never used them. On of best articles I found about i18n in ASP.NET is a 3-part article series from Code Project. You can read them here: Part 1, Part 2 and Part3.

The core concept in i18n in ASP.NET (esp. in ver. 1.x) are resource files (with .ascx extension) and satellite assemblies.

In this series of articles Karl Sequin suggested not using satellite assemblies and build a resource manager from beginning. The reason he don't like resource files and satellite assemblies is that because resource files are compiled into satellite assembiles, if you want to change a small word in translated files you should stop your web server or web site and upload new .dll files. I believe that in large scale projects he is absolutely right but in my case resource files are better choice.

If you like to know more about i18n in ASP.NET 2.0 you should take a look at Part 3 which Provider Factory Pattern are discussed.


 
Categories: ASP.NET | i18n | Web