A nice day



What to start with, ASP.NET or PHP?

For further reading, more php and asp.net codes please go to Sanjib’s Scribble
Well, I’d like to write about this in INDIAN context. That is, I presume, you are about to start your journey as a web developer in India, and thinking about learning a web language. Now, keeping this condition in mind, what you’ll do? What will you learn first? And why this but not that?
I’ll keep writing it in several parts. Because I have not enough time and bandwidth in my data card to keep going on for a long journey, but I promise I’d keep it as short as possible.
Before starting I’d apologize for not including Python, Java or Rubi on Rails in my discussion mainly for two reasons.
1) I don’t know them.
2) For dynamic web site, the competition is fierce between these two technology and I have some live experiences about them.
If you are Indian, PHP is the best options for you to start. Not ASP.NET. Why?
Let me write down the reasons first. Next I’ll explain them in detail. I don’t claim, that this is final judgement and won’t suggest you to follow my reasons blindly. What I write, writing from a realistic point of view. You may agree or disagree. Whatever your opinion I’d like to get your comments.
Here are the reasons why PHP is better to start with.
1)Cost effective.
2)Open source.
4)You don’t have to buy any software.
5)A good demand in small or medium company.
6)Takes less time to learn and start with.
7)Compactness and simple integrity with MySql database.(If you can conceptualize array, 50% job has been done!)

Now I’d like to clarify from my experience. One by one.

1) Cost : As a web developer, you’ll find that cost will play a very important role in the future. Whenever, you’d like to contact a hosting company they will always ask more money for a windows hosting which is needed for ASP.NET. For PHP you need Linux hosting that is almost half the amount for the same space and bandwidth. In Windows, it takes more cost because you need to hire an extra SQL Server. In PHP, MySql is in-built. So you need not spend extra dime for it. Form my experience I can say, in Linux hosting there are other advantages or features like blog, wiki, E-Commerce, image gallery projects like wordpress, phpbblog etc. In windows hosting you can not take advantage of such open source frameworks. What ever you want to do in ASP.NET, you have to do single handedly.
Some will argue here, there are many starter kits and open source projects available in ASP.NET also that you can download free from asp.net official site. Then where is the difference?
The difference is in installation process. In ASP.NET you may find some open source projects like blog, wiki etc. But to install them in a separate folder is quite cumbersome. On the contrary, WordPress or PHPBB type projects(run in php and MySql) are ready to install easily and quite user friendly.
So LAMP is not cheap in that sense but cost-effective.
2) Open Source
PHP/MySql is Open Source. If you want to learn more about it, please google it or read Wikipedia. You’ll get more idea about it. Basically it means, it is free, easy to use and there are much more free support from the community in every step. You can also edit the source code that you get from elsewhere.
ASP.NET is more user friendly, no doubt. But, if you want to learn the basic, core ideas on which the passage of data depends, then PHP is the best bet. If you can conceptualize array, then 50% job has been done.
4) You don’t have to buy any software.
To learn PHP/MySql you need not buy any software. This is free and that is why it is so much popular.
5)A good demand in small or medium company.
As the job market is concerned, small or medium level companies opt for free open source softwares. So PHP developers are in demand always.
6)Takes less time to learn and start with.
If you are from a computer background learning PHP is much easier. Logic plays a vital role. If you can follow the logic, how the logic flows, how data transfered from one page to other through array(name=>value) combination, the job has been done.
7)Compactness and simple integrity with MySql database.(If you can conceptualize array, 50% job has been done!)
The best friend of PHP is MySql. They are like Marx and Engels. You may type SQL in your PHP page and get the desired effect in your web page. Also, the hosting companies come with this great combinations so you start with an advantage.

How you’ll get your Membership.ValidateUser() to Work

Recently I’ve come across a intriguing question in asp.net forum. One member from Canada asked that his membership.validateuser() method is not working. Actually, what happened, according to him :

Long ago I implemented the Login control on a login page and I thought all was working. Testing has revealed that if you first enter an incorrect password but then next enter the correct password, the Login control fails to log the user in until they enter the correct password a second time. This is unacceptable.

So I began investigating what is wrong and quickly discovered that Membership.ValidateUser(username, password) is failing to return true even though I’m entering the correct credentials. I’ve done much research and discovered that plenty of other developers have experienced the same problem. As of yet, I have not found a solution to my particular problem so I thought I should try seeing if I could get an answer here.

In web.config here is the pertinent info related to Memberships:

If anyone could tell me why they think that Membership.ValidateUser() is consistently failing to work, I’d much appreciate it!

Now I found that, PasswordAttemptWindow is missing in his web.config file. So my answer was :

It probably happened because you’ve not set the PasswordAttemptWindow to some exact time. That is why, I gave you a code to test, in my code it is set to 10.

If you kindly go through what MSDN says about it, you’ll understand why it is locked out no matter what value you’ve set for MaxInvalidPasswordAttempts.

MSDN says:

“The MaxInvalidPasswordAttempts property works in conjunction with the PasswordAttemptWindow property to guard against an unwanted source using repeated attempts to guess the password or password answer of a membership user. If the number of invalid passwords or password answers entered for a membership user is greater than or equal to the value of the MaxInvalidPasswordAttempts property within the number of minutes specified by the PasswordAttemptWindow property, then the user is locked out of the Web site by setting the IsLockedOut property to true until the user is unlocked by a call to the UnlockUser method. If a valid password or password answer is supplied before the value of the MaxInvalidPasswordAttempts property is reached, the counter that tracks the number of invalid attempts is set to zero. Invalid password and password answer attempts are tracked separately. For example, if the MaxInvalidPasswordAttempts property is set to 5, the user has up to five attempts to enter a correct password and up to five attempts to enter a correct password answer without being locked out. The MaxInvalidPasswordAttempts property value is set in the application configuration using the passwordAttemptThreshold attribute of the membership Element (ASP.NET Settings Schema) configuration element. ”

Best of luck.

I would like to share it for many reasons, mostly because, people often get stuck in creating Membership API in ASP.NET forgetting that there are many small, subtle but very important aspects that to be considered.

To get it into detail, you may visit the original post here :
asp.net forum
My Site
PHP/MySql Blogs
PHP/MySql Blogs

How to set Roles and access to certain pages

In ASP.NET forum very often a question is asked. How to set Roles and accordingly restrict access to certain pages?

There are definitely various ways. But I prefer UserControl. Its advantage is you can drag it to the Masterpage and its functionality has been used all along your application.

Here the main problem is I can’t use the code so I upload codes as Images part by part.

Here is the code:

set Roles and access to certain pages

set Roles and access to certain pages

set Roles and access to certain pages

set Roles and access to certain pages

set Roles and access to certain pages

set Roles and access to certain pages

set Roles and access to certain pages

set Roles and access to certain pages

set Roles and access to certain pages

set Roles and access to certain pages

Here I used few controls like LoginView, LogInStatus and lastly in the Page_Load event handler I checked whether User.Identity.IsAuthenticated. It can be used as User.IsInRole also to check the user belongs to a certain Role or not.

In this way, one can check whether a user belongs to the Role Administrator or Member, if he/she is Administrator can go to CatalogAdmin.aspx and if he/she belongs to the Role of  Member, then he/she might have access to Member_1.aspx page.

Passing data between pages in ASP.NET

On a stateless protocol such as HTTP, and ASP.NET on the server side, how do you manage state on the Web?
Actually to pass data from one page to other page in ASP.NET, you can use several techniques.
You imagine something like this: http://… /page.aspx?state=some
So basically it’s about state mangement. And please remember there is no right answer.
There are some server side options : Application state, Cache object, Session state, Database.
Some client side options : Cookie, Hiddden field, ViewState, ControlState, QueryString (URL).
There is a great debate, which one is best?

Apple versus Microsoft

Probably this news did not go unnoticed. Now Steve Jobs’ Apple is most valuable tech firm in the world and in NASDAQ it overtook old rival Bill Gates’ Microsoft.
Okay I’m a not a financial market expert nor I’m a tech guru so I can explain the nittygritty of this up and down.
What I can do is sharing my experience with Microsoft technology as a ASP.NET web developer. In a nutshell, Microsoft technology is superb. From the web development point I can say, it is almost unparallel. It is very very much user/developer friendly but not developing country friendly. 🙂
I hope you get my point. When you build a web site with visual studio, you can get the free versions of VS and SQL Server(Express) but a child knows you can not download it using a pirated Windows.
So here is the catch. You must buy a genuine Windows. DO you know how much it cost in a developing country?
In our country, India, a small percentage of people can buy that. Seventy percent (more than seventy crore) is BPL. Twenty five percent belongs to the Middle income group but not that all can buy genuine softwares.
So in India, like other developing country, there is a vast market of piracy. You have brilliant teams. Great thinkers who can make impossible things possible. Microsoft has everything to make technology talk. But what is the use of brilliance if that does not serve mankind, general people?
DO we really have something to do with this win and lose? Nothing at all. Apples’ IPad is too costly and moreover you can not probably download a pirated version from the internet.
So it really does not matter, who overtakes whom. Still Microsoft’s technology comes to our help. Microsoft definitely knows about the piracy, but until now it goes on and people with no money, can use their pirated softwares to make their living.
That is the good side of the Microsoft story. I don’t know how Apple’s technology will come to the help. Hopefully it’ll come.