Friday, October 10, 2008

Using Web.Config for Authentication - ASP .NET Web Application

IDE Used: Visual Web Developer 2008


I think for small web application with a few number of application users, storing login credentials in Web.Config file of the web application should be okay, this may not adhere to .Net Web Application best practices but using a database doesn't make sense. I tried reading encrypted login data from a file but it didn't seem like very portable. For some reason, storing login data in Web.Config looks perfect. So here is how you do it:

1- Open up the Web.Config file of your ASP .Net Web Application
2- Scroll down until you see the xml Authencation tag.
3- Change that to XML below, please use the valid "<" ">" for xml tags. I have used "[" "]" because blogger wouldn't allow me to display XML on pages.

      [authentication mode="Forms"]
        [forms loginUrl="default.aspx"]
          [credentials passwordFormat="Clear"]
            [user name="familyguy" password="peter" /]
          [/credentials]
        [/forms]
      [/authentication]

But for this work, you need to make some more changes to your .Net Class code which controls the behavior of your Login page. But before I go ahead and show the authentication code, the:

username is : familyguy
password is : peter

Following is what I added to my C# code that controls the ASP Login page

if (FormsAuthentication.Authenticate(usernametextbox.Text, passwordtextbox.Text))
{
Response.Redirect("profile.aspx");
}


The first line of the C# code is the method call which returns a boolean. The method takes in username and password entered by the user in the textboxes (input controls) on the login pages, as input parameters.
If the correct username / password, familyguy / peter, is entered, user will gain access to the next page which is "profile.aspx" in my application. Response.Redirect("profile.aspx") in the body of the IF condition of the C# code is responsible for loading the next page in the browser.

Thursday, October 9, 2008

ASP .NET – Allowing Authenticated users to see web application pages only

If you have implemented log-in, log-out capability in your ASP based Web Application then one of the main goals is to make sure unauthorized users do not get access to the pages within your web application. In other words, they must first login in order to get access to any information contained in the rest of the pages of the web application

                To make my point clear, lets assume we have a web application which is composed of 3 aspx pages:

  1.  Login.asp
  2. Profile.aspx
  3. Preferences.aspx

And we want user to land on Login.aspx first, enter their username and password and then get redirected to Profile.aspx and after filling out all the fields on Profile.aspx, Preferences.aspx is displayed in the users’ browser.

Web Server can be configured to take the users directly to my Login.aspx page when they type in the URL of the website, but I noticed that if the users want, then they can directly go to Profile.aspx and Preferences.aspx, something which I do not want to happen.

How to overcome this problem (assuming your Log-in and Log-out components are implemented correctly). The following piece of code is in C# (c sharp).

In the        Page_Load(object sender, EventArgs e)        method in C Sharp Code file associated with your ASPX page, embed your entire logic (code) in the following IF Condition:

            if (Request.IsAuthenticated)    //checking if the user trying to access the page is authorized

{
       //your entire Page_Load ( …. ) logic goes here in this IF condition
}

else

{             
                       Response.Redirect(“login.aspx”) ;     //This will take the user to your Login page
             }

If the user is not authenticated, not authorized, then the user will be taken to your default Login.aspx page to enter username/password before accessing any other pages of the application. The “else” condition in the above code snippet is responsible for taking the user to youlogin page, login.aspx

Saturday, October 4, 2008

Folliculitis - Found a cure that atleast works for me

I don't think describing and going into the details of Folliculitis is important, as it's sufferers know exactly what it is and are probably sick and tired of reading the same info on folliculitis again and again.
I am suffering with Folliculitis for the past 10 years. The initial area that was affected by Folliculitis were the hair on the back of my head. It was isolated for many years to the left side of the back of the head and that was it. Although it was very mild but persistent, I never really paid much attention to it and occasionally went to my dermatologist who always prescribed antibiotics which always cleared up the infection quickly and prevented re-infection for the next 30 - 40 days and then folliculitis would come back again. What I failed to realize was that everytime it was coming back, it was coming back with a little more force. In other words, it started spreading and its severity was increasing. 
That is when I started taking it seriously and started visiting different doctors to see if anyone can come up a with a miracle drug and make my folliculitis go away. Every doctor suggested different antibiotics, some worked, others didn't, the ones that worked eventually stopped working. And after 10 years with folliculitis and taking antibiotics continiously for the past 5 years, my doctor refused to prescribe any more antibiotics and suggested I use topical antibiotics instead. I went to another doctor, who after listening to my story, refused to prescribe any antibiotics also and suggested topical antibiotics. 

I dont like the idea of topical antibiotics and never bought the medications they prescribed. My folliculitis was severe than ever, pretty much affecting my entire head. It became very difficult to put my head on the pillow because of the pain.

I would like to mention that I have kept on trying different products such as garlic, honey, vitamins, flax seed, many things to fight folliculitis but nothing ever worked and I would admit, I was not consistent. I would try something for a week or 10 days and if I didnt see any positive results or improvement in the condition, I would run to my doctor and get some antibiotics again to clear up the infection.

But after 5 years on antibiotics, the doctors I knew and who knew me refused to give any more antibiotics. 
So I started asking my self this question: What is something natural that I havent tried yet that may fix my problem? And the answer that I got was, "ALUM, Shaving Alum". I think it is also known as Potash Alum (please verify)
I went to a store, and bought two small rectangular blocks of Shaving Alum from them, paid about $5 including taxes.
Started rubbing Shaving Alum on my head after taking shower every morning and within 2 - 3 days, I started feeling the difference. My folliculitis was fading, going away, the bacteria seemed weak, disappointed and unhappy. I kept on applying Shaving Alum continuously for the next three weeks. The only problem with Alum is that it has a drying affect on the skin and since I was rubbing it too much on the scalp, it left powdery residue in my hair and my hair looked more like an extremely bad case of dandruff. 
I kept on applying it without worrying too much about what people would think. In three weeks, the affected area was folliculitis free. I was happy but since I am not consistent with anything, I stopped rubbing Shaving Alum every single morning. But its been four week now since I stopped using Alum every morning and seems like Alum is still working or maybe folliculitis has packed up and left for ever (i hope so).

I do not know if Shaving Alum has any negative side effects on hair or skin. My goal was to get rid of Folliculitis and I achieved that. I do not think that Shaving Alum  (Potash Alum) has any harmful effects as people use it on skin after shaving. But to avoid any problem arising due to shaving alum, instead of applying it every morning, I now apply it once or twice a week. And I will admit it has done what antibiotics were not able to do. 

Note: Applying Alum on the folliculitis affected area has helped me but it may not work for everyone. The reason for writing this article was to let other folliculitis sufferers know that there is something out there that has atleast helped one folliculitis sufferer. But I am not in anyway trying to say that this is a definite cure. Please consult your dermatologist and know about all the risks and harmful effects of Alum before you give it a try.

Friday, October 3, 2008

Compiler Error Message: CS0122

Complete Error Message:

Compiler Error Message: CS0122: 'xxxxxxxxxxxxxxxxxxxxxxxxxxx' is inaccessible
due to its protection level

In my case, Button's "onclick" event was actually calling a method which I made "private" by mistake. Changing the method to "protected" took care of the error.

The error is implying that the method, or object that you are trying to access is inaccessible due to its protection level. In other words, in order to access the object/method, you need to relax the level of protection on the object. So, if the object is "private", make it "protected" and see if that makes the compiler error CS0122 go away.
Compiler Error Message: CS0122: ' ' due to its protection level
Compiler Error Message: CS0122: ' ' due to its protection level
Compiler Error Message: CS0122: ' ' due to its protection level
Compiler Error Message: CS0122: ' ' due to its protection level
Compiler Error Message: CS0122: ' ' due to its protection level
Compiler Error Message: CS0122: ' ' due to its protection level
Compiler Error Message: CS0122: ' ' due to its protection level
Compiler Error Message: CS0122: ' ' due to its protection level
Compiler Error Message: CS0122: ' ' due to its protection level
Compiler Error Message: CS0122: ' ' due to its protection level
Compiler Error Message: CS0122: ' ' due to its protection level
Compiler Error Message: CS0122: ' ' due to its protection level
Compiler Error Message: CS0122: ' ' due to its protection level
Compiler Error Message: CS0122: ' ' due to its protection level
Compiler Error Message: CS0122: ' ' due to its protection level
Compiler Error Message: CS0122: ' ' due to its protection level
Compiler Error Message: CS0122: ' ' due to its protection level
Compiler Error Message: CS0122: ' ' due to its protection level
Compiler Error Message: CS0122: ' ' due to its protection level
Compiler Error Message: CS0122: ' ' due to its protection level
Compiler Error Message: CS0122: ' ' due to its protection level
Compiler Error Message: CS0122: ' ' due to its protection level
Compiler Error Message: CS0122: ' ' due to its protection level
Compiler Error Message: CS0122: ' ' due to its protection level
Compiler Error Message: CS0122: ' ' due to its protection level
Compiler Error Message: CS0122: ' ' due to its protection level
Compiler Error Message: CS0122: ' ' due to its protection level
Compiler Error Message: CS0122: ' ' due to its protection level
Compiler Error Message: CS0122: ' ' due to its protection level
Compiler Error Message: CS0122: ' ' due to its protection level
Compiler Error Message: CS0122: ' ' due to its protection level
Compiler Error Message: CS0122: ' ' due to its protection level
Compiler Error Message: CS0122: ' ' due to its protection level
Compiler Error Message: CS0122: ' ' due to its protection level
Compiler Error Message: CS0122: ' ' due to its protection level
Compiler Error Message: CS0122: ' ' due to its protection level
Compiler Error Message: CS0122: ' ' due to its protection level
Compiler Error Message: CS0122: ' ' due to its protection level
Compiler Error Message: CS0122: ' ' due to its protection levelCompiler Error Message: CS0122: ' ' due to its protection level
Compiler Error Message: CS0122: ' ' due to its protection level
Compiler Error Message: CS0122: ' ' due to its protection level
Compiler Error Message: CS0122: ' ' due to its protection level

Wednesday, October 1, 2008

Life On Other Planets

I don't understand why outer space experts and scientists think that presence of water is the only indicator of life anywhere in the universe. It is true that life on earth is mainly due to the presence of water but I don't think water is the only pre-requisite for life.

And by the way, what is LIFE?
Our definition of life is based solely upon our understanding of Life. In other words, we are very biased. 
What if there is Life everywhere but we just dont have the ability or capability to detect it? What if there is life on Mars that doesn't need water for existence? What if Mars inhabitants consider water to be the deadliest poison and are trying their best to get rid of it? 

I think we should stop spending millions and billions on space exploration as it not really going to solve any of the problem we are facing here at home.
Spending so much just to find water on planet X and to find out if it is inhabitable or was inhabitable in the past, is just BS!
Lets take care of the people on this planet who "really exist" and "really need water" but are dying just because they don't have to clean water supplies.
I think space agencies should be turned into water purification companies to bring bottled water prices down by creating more competition.

Computer pre-loaded with movies? Whats this?

I was reading on Washington Post's tech-crunch that Dell in partnership with Paramount Pictures will be offering some computer models with pre-loaded movies. See the link below to read the details of the story:

Is this a joke? 

It may help Paramount pictures because they have an additional way of selling their movies. But how is it going to help Dell? I think Dell is being run by some really stupid people. 

Okay, so, I like Iron-Man, lets buy a Dell XPS and get it pre-loaded with Iron-Man by paying an additional $20 - woohooooo!

OR

When buying a new Dell Computer, I will also see the following upgrade options:
- Additional 2 GBs of RAM
- Extra 200GB of HDD
- Microsoft Office
- Iron Man (YES!!!! - only $20)

I think this is enough to get an idea of the sad situation of the company, Dell.
As of this writing, Iron Man is the only movie you can get (pre-installed) on your new Dell System.
Is this supposed to make people buy Dell computers?
Or, is this supposed to make movie collectors into Dell buyers? Maybe movie collectors will also become "Dell Collectors". 

Maybe Apple should do this also because this gimmick may work very well with MAC lovers, who are nothing but stupid people, totally out of touch with the reality. Actually MAC buyers are so stupid that they would get the same movie pre-installed more than once thinking that it may help them look more "COOL".

May God help Dell




Monday, September 29, 2008

My Experience With Bernardi Acura of Boston

Buying a used car from Bernardi was a hoooooooooorible experience; it was like going through torture. All I got was broken promises, lies and more lies. Bernardi says, “We believe honesty is the ONLY policy”; and I think DISHONESTY is the only policy they know.

Here are few broken promises or lies they told me:

Lie 1: Bernardi promised the car will be ready in 1 day after the payment is made. I needed the car right way to commute to work. It took them 12 days to get the car ready and serviced. I had to take bus to get to work which was 4 hours of commute everyday. Moreover, I had to call atleast 3 or 4 times before they would call me back. Every single time, they would tell me your car will be ready tomorrow; and we are Bernardi Acura, we deliver our promises. THE BIGGEST LIE.

Lie 2: They offered me 2 yr/ 24,000 miles warranty on the car, which I bought from them. A week later, I got a call from Bernardi telling me they can’t offer 2yr/24,000 miles warranty because my car is a 2001 model. If they couldn’t commit then why did they make a promise at the first place????

Lie 3: We offer 90-day warranty on all our used cars. Guess what!!! They don’t and I found it after buying the car that my car had only 30-day warranty.

I would never go back to any of the Bernardi’s dealerships, even if I have to buy a brand new car. For Broken Promises and Lies, WELCOME TO BERNARDI!!!!!!!!

Review contributed by : MAT

Flare Kit Headline Animator