Click here to Skip to main content
15,881,607 members
Please Sign up or sign in to vote.
2.33/5 (3 votes)
See more:
if(Session["user"]=="admin")
{
}

but condition is not working.

please tell where i get wrong.

Thanks in advance
Posted
Updated 15-Jun-11 19:39pm
v2
Comments
Sergey Alexandrovich Kryukov 16-Jun-11 1:59am    
Please do not re-post.
--SA

Apart from being poorly written in general, the code is fine, it will do exactly what you're asking it to. The question is, what is wrong with your overall design to cause this code to not do what you want, why have you been asking the same question for days, why can't you provide more information, such as what is going wrong, what you've found when you use the debugger, etc ?

I suspect the answer is that you have no clue what you're doing and should not be writing code that obviously is handling a secure aspect of a website. Does anyone else in your company know anything about writing good code, or is your client just flat out being ripped off ?

I've given you good advice before, and I see you've not followed it, so pardon me if I don't bother trying to help someone who refuses to listen.
 
Share this answer
 
Comments
rahul dev123 16-Jun-11 1:57am    
Before telling something please see the code and try to give the answer. i am not a expert, i am a student and i try to learn and develop something. In this code i had mistake to Convert it into string, after convert it works fine but u can't do to give the correct answer.
Sergey Alexandrovich Kryukov 16-Jun-11 2:08am    
Why do you think he is obliged to approach your answer the way you suggest?

I understand, the answer is harsh but it can cause you to think seriously about your work. Instead of protecting your ego (but would it help you?) you could draw some conclusions about your attitude, in particular, to the little attention you tend to pay for good solutions. You are also trying to make excuses based on being a beginner. A person who asked 107 question is not so much of a beginner. A beginner is the one who begin and make progress, not the one who makes excuses and return to the same mistakes over and over, not trying to ask questions more constructively.

You have to read some unpleasant words right now, but you've asked for it. Nobody want to publicly spank you -- there is no proud in it in experienced people, people a are trying to help.

Best wishes,
--SA
Sergey Alexandrovich Kryukov 16-Jun-11 2:11am    
Cristian, despite of all your harshness (and I'm afraid to say you make mistakes sometimes and not very thoroughly weight your words), I agree with you in this case and vote 5.
--SA
Christian Graus 16-Jun-11 6:44am    
Fact is, I had solved this and generally advised this person yesterday on why I'd fire anyone who used code like this. He took none of my suggestions. The first time he asked, I was happy to help. When he asks over and over, and, despite being told, can't even ask a clear question, then I feel I am right to tell him that he needs to lift his game.
Sergey Alexandrovich Kryukov 17-Jun-11 22:12pm    
I took a look at your post you mentioned; thanks for the note anyway.

I know 4-5 members here who seemingly completely incapable of getting any help or advices. Post of some of them turned to a permanent spam and abuse. Worse, some members goes really rude which I don't want to tolerate ("If you don't know the answer, don't tell anything; I don't need your useless advices", stuff like that). See OP's reply to the answer by CS2011. I think some warning followed by suspension of account can be considered.

--SA
what is wrong with you.We are not magician here.There is nothing wrong with the condition apart from your code does not do anything even if the condition is satisfied.You want us to help you tell us where and what is the problem.
 
Share this answer
 
Comments
rahul dev123 16-Jun-11 1:50am    
If u don't no the answer please keep quiet. Here is the answer, i have solved this:
if(Convert.ToString(Session["user"])=="admin")
{
// statements
}
CS2011 16-Jun-11 2:06am    
Really Dude...Have you seen me going around asking same question for days.First you should learn how to phrase a question.You asked what is wrong with the code above and there is absolutely nothing wrong with the code.it will compile without any error.
Sergey Alexandrovich Kryukov 16-Jun-11 2:13am    
This is rude! How dare you? Please get back to your feeling to avoid suspension of your account for indecent behavior.
--SA
Christian Graus 16-Jun-11 6:47am    
You're an idiot. You did not solve it. Someone told you the answer. And, everyone looking at your code would have known the answer, if we'd known what the question was, that is, if you'd bothered to tell us the error message. As it stood, your question was half formed. Also, you took NONE of the advice I gave you on why this is horrible code, that no-one should ever use. If you don't want to learn, why are you asking ?
Sergey Alexandrovich Kryukov 16-Jun-11 2:14am    
Agree, my 5 for the answer. Please see my comment to OP. This is beyond any acceptable behavior.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900