ASP.NET'te Login olan kullanıcı nasıl yönlendirilir?

March 26, 2009 at 10:52 AMoozturk

ASP.NET bildiğiniz gibi roles, profiles, members, vs.. bir sürü özelliği zaten içinde barındırıyor ve ayrıca bir daha bunlar için efor sarfetmeye gerek bırakmıyor. Bunları kullanıyoruz ancak login kontrolü birçok sayfaya uymuyor ve kullanmıyoruz ya da template'e çevirip sonra değiştiriyoruz. Peki bu durumda nasıl yönlendirme yapacağız?

 

Eğer login kontrolü kullanıyor olsaydık, zaten Loggedn event'i ile bunu yapmak çok kolay olurdu ama kullanmıyoruz, o zaman aşağıdaki gibi bir çözüm var.

 

Kullanıcı; kullanıcı adını ve şifresini yazıp da giriş tuşuna bastığında aşağıdaki koda benzer bir kod yazarak istediğimiz gibi yönlendirebiliriz.

 

        if (Membership.ValidateUser(txtUsername.Text, txtPassword.Text))
        {
            bool rtnVal = false;
            if (chkRememberMe.Checked)
                rtnVal = true;

            FormsAuthentication.SetAuthCookie( txtUsername.Text, rtnVal );


            if( buraya gereklı durumu yazın )
                Response.Redirect( "adresi de buraya" );
            else
                Response.Redirect( "ya da buraya" );
        }

 

Yukarıdaki kod'da bir checkbox da var ve eğer kullanıcı isterse bir cookie yaratıp kullanıcı daha sonra tekrar geldiğinde bir daha giriş yapmasına gerek kalmaz. Önce kullanıcnın belirttiği bilgileri kontorl ediyoruz, daha sonra setAuthCookie ile gerekli session ve cookie lerin düzenlenmesini sağlıyoruz. En altta ise dilediğimiz gibi yönlendiriyoruz.

 

Bu kadar basit.

Posted in: ASP.NET

Tags: ,

Comments (102) -

I like that you've touched on this subject, it's somewhat of a rariety.

Reply

Extremely inspiring. It's amazing what can be done when we put our minds to it.

Reply

I just stumbled on your blog when I was lookng on google. I have to say that the information here was the most complete that I found anywhere. I am definitely bookmarking this to come back and read later.

Reply

I was wondering where you got your layout? Its great Looking.

Reply

I was very pleased to find this site.I wanted to thank you for this great read!! I definitely enjoying every little bit of it and I have you bookmarked to check out new stuff you post.

Reply

Wow everybody looks like they love this blog. It's a good blog.

Reply

I love reading through blogs like this one. Very informative and an interesting point of view.

Reply

I just wanna thank you for sharing your information and your site. I've learned something today. Thanks!

Reply

I wish more people would write blogs like this that are actually fun to read.  With all the fluff floating around on the net, it is rare to read a blog like yours instead.

Reply

Hello - I must say, I’m impressed with your site. I had no trouble navigating through all the tabs and information was very easy to access. I found what I wanted in no time at all. Pretty awesome. Would appreciate it if you add forums or something, it would be a perfect way for your clients to interact. Great job!

Reply

This is very interesting. I actually enjoy your writing style and your word choice more than anything Smile

Reply

I must say that overall I am very taken with this site. It is apparent that you know you subject matter and you are passionate about it. I wish I had got your ability to write. I have bookmarked your site and look forward to more updates.

Reply

This is a useful post, but I was wondering how do I suscribe to the RSS feed?

Reply

I'm not such an expert when it comes to this. Useful read, appreciate your posting this.

Reply

This really is my very first time i visit here. I discovered so numerous fascinating stuff in your weblog particularly its discussion. From the plenty of comments on your content articles, I guess I am not the only one having all the enjoyment right here! keep up the great work.

Reply

I was looking for this the other day. i dont usually post in forums but i wanted to say thank you!

Reply

I know this isn't exactly on topic, but I have a blog using the blogengine platform and I'm having problems with my comments displaying. Is there a setting I am forgetting? Maybe you could help me out? Thanks!

Reply

Perhaps you have thought about putting a few video clips to your site to keep the readers more entertained? I mean I just read thru the entire article of yours and it was ok but since most people are more of a visual learner, I found that to become more helpful. Well please let me know how it turns out! I love what you people are doing and up too. Such smart work and opinions! Keep up the great work guys. I've included you guys to my page links. This is a great article thanks for sharing this informative information.. I will visit your blog regularly for some latest post.

Reply

You really know your stuff... Keep up the good work!

Reply

This is a useful post, but I was wondering how do I suscribe to the RSS feed?

Reply

Thanks for sharing these useful information! Hope that you will continue doing nice article like this. I will be one of your loyal reader if you maintain this kind of post!This is one of the best post I found so far. The contents are very good and very informative.I subscribed to your RSS feed by the way!Thanks, this is really cool!

Reply

I like to take a break during the day and browse through some blogs to see what people are talking about. This blog appeared in my searches and I could not help clicking on it. I'm happy I did because it was a very interesting read.  

Reply

I just stumbled on your blog when I was lookng on google. I have to say that the information here was the most complete that I found anywhere. I am definitely bookmarking this to come back and read later.

Reply

When I firstly saw your web, I've been around in many pages that I'll use to get my final assignment. I googling with my short idea in my brain, and then I met with useful article. I hope you can give several advices to me, because your knowledge is great, it can help many students to get great score in every task or project. If you don't mind, I will contact you to make short discussion for my project. I write my short comment for you to give support for your site; my friends had used your article as reference in specific term and condition. After that, my friends are satisfied with your article (I've given reference to read many pages in your site). We can make other discussion later, because it will be worth to me. Thanks in advance, hope you contact me, so we can broaden our knowledge together.

Reply

I'm not such an expert when it comes to this. Useful read, appreciate your posting this.

Reply

Qute absorbing. I'd absolutely like to read more about this. Does anybody have any advice where I can acquire some further resources? Appreciate it.

Reply

Hi,

I just wanted to say that I have been following for a a couple of days and I would like to sign up for the updated feed.

Reply

I am not really sure if best practices have emerged around things like that, but I am sure that your great job is clearly identified. I was wondering if you offer any subscription to your RSS feeds as I would be very interested and can?t find any link to subscribe here.

Reply

Hi,

I just wanted to say that I have been watching for a while and I would like to sign up for the feed. I'll give it a try but I might need some assistance. This is a good find and I would hate to lose contact, and maybe never find it again.

Anyway, thanks again and I look forward to reading/posting again in the future!

Reply

I like the layout of your website and I’m looking to do the same thing for website. Do you have any tips? Please PM ME.

Reply

When are you going to post again? You really inform  a lot of people!

Reply

This really answered my problem, thank you!

Reply

I'm getting a browser error, is anyone else?

Reply

Amazing article, thank you, I will visit again soon!

Reply

This really answered my problem, thank you!

Reply

Just discovered this blog thru Google, what a way to brighten up my year!

Reply

This blog is very good! How did you make it .

Reply

This site has got some very helpful stuff on it. Thank you for informing me!

Reply

A insightful blog post there mate . Thanks for that !

Reply

This website has lots of very helpful information on it. Thanks for helping me.

Reply

After reading this I thought it was very informative. I appreciate you taking the time to put this blog piece together. I once again find myself spending way to much time both reading and commenting. What ever, it was still worth it

Reply

This really answered my problem, thank you!

Reply

Have you considered adding some videos to the article? I think it will really enhance viewers' understanding.

Reply

Wow! This blog site is sick! How do you  make it look like this .

Reply

Could you email me with any tips on how you made this blog look this cool, I would appreciate it.

Reply

this was a very entertaining read.  i enjoyed it very much!

Reply

Zero Nicotine is safe and easy to use. Each patch contains a dose of the most effective herbal ingredients, formulated to alleviate the symptoms of nicotine withdrawal while cleansing the system of all smoking-related toxins. To break free from smoking, you need to break free from nicotine. Unlike other stop smoking patches, Zero Nicotine’s all-natural formula contains NO NICOTINE and eliminates, rather than replenishes, the level of nicotine in your body, helping you break the habit. Used in conjunction with our proven cessation program, these Patches can help you be free of tobacco in thirty days or less.

Reply

great post! i'm bookmarking this!

Reply

With ease, the post is really the greatest on that precious topic. I harmonise with your conclusions and will certainly thirstily look forward to your incoming updates. Simply just saying thanks definitely will not simply just be sufficient, for the extraordinary lucidity in your writing. I definitely will instantly grab your rss feed to stay abreast of any updates. Genuine work and much success in your business endeavors!

Reply

This is actually the 2nd occasion I have noticed your site within the last few weeks.  Appears like I should take a note of it.

Reply

Merely want to say your article is as tonishing. The clearness in your post is simply striking and i can assume you are an expert on this field. Well with your permission allow me to grab your rss feed to keep up to date with incoming post. Thanks a million and please keep up the gratifying work.

Reply

awesome layout and good write-up.many thanks this is terrific info

Reply

great post! i'm bookmarking this!

Reply

Amazing blog post, plenty of quality info.  I am going to show my buddies and ask them the things they think.

Reply

Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts.

Reply

This is such a great resource that you're giving and you give it away for absolutely free. I enjoy seeing websites which recognize the value of giving a excellent resource for absolutely free.

Reply

lol I've always thought that iPads are great gadgets and find them really intuitive to use.

Reply

Neat I've always reckoned that iPads are neat gadgets and find them hyper easy to use.

Reply

Thank you for the information. The internet is so cluttered with crap it is difficult to find what you're looking for these days. Have you got an RSS feed on this blog?

Reply

Thanks for the interesting read. The web is so full of garbage it's becoming difficult to find exactly what you are looking for nowadays. Do you have feed on this site?

Reply

I like your blog, for me one of my favourite websites. Keep on the good work, Sabrina

Reply

Thanks for the info. The internet is so full of junk it is difficult to find exactly what you're looking for nowadays. Do you have RSS on this site?

Reply

This is a nice blog. Good clean UI and nice informative blogs. I will be coming back in a bit, thanks for the great post. I admire what you have done here. I love the part where you say you are doing this to give back but I would assume by all the comments that is working for you as well. Do you have any more info on this

Reply

I have been reading your blog posts during my afternoon break, and I have to admit the whole article has been very valuable and very well written. I thought I would let you know that for some reason this blog does not view well in Internet Explorer 8. I wish Microsoft would quit changing their software. I have a question for you. Would you mind exchanging blog roll links? That would be really cool!

Reply

I didn't see a hyperlink anywhere but do you sell ad space? I have several sites within the exact same specialized niche and I'd like to add my banner somwhere in your site.

Reply

Hi  blog im from manchester im thinking of doing a manchester solicitors blog, thanks for your info i got some useful tips for my blog.

Reply

This is such a wonderful useful resource that you'll be providing and you provide it away for free of charge

Reply

Mate. This blog site is sick. How did you  make it look like this !?

Reply

This blog site is very cool. How can I make one like this ?

Reply

Dude. This site is cool. How do you  make it look this good .

Reply

Wow. This blog is cool. How did you  make it look this good .

Reply

Cool post ! Thank you for, posting on my blog dude. I shall email you soon. I didn't know that.

Reply

Only want to say your article is striking. The clearness in your post is simply impressive and i can take for granted you are an expert on this field. Well with your permission allow me to grab your rss feed to keep up to date with succeeding post. Thanks a million and please keep up the fabulous work.

Reply

Cool post ! Thanks for, visiting my blog page man. I will message you some time! I did not know that.

Reply

How do you make this blog look this awesome. Email me if you want and share your wisdom. .

Reply

is this a free template, it would suit my blog perfectly - whats the name

Reply

I adore the website layout . How did you make it? It is very sweet.

Reply

Have you considered adding some differing opinions to the article? I think it might enhance viewers' understanding.

Reply

This blog keeps me coming back. I love your work.

Reply

It sounds like you're creating problems yourself by trying to solve this issue instead of looking at why their is a problem in the first place. how does this compare to watches.realbeauty.info/...elry-box-carefully.aspx

Reply

When are you going to post again? You really entertain  a lot of people!

Reply

How do you make your blog site look this sick! Email me if you get the chance and share your wisdom. I'd appreciate it!

Reply

If you could email me with some hints about how you made your website look this good , I would be thankful.

Reply

Please message me with some pointers on how you made your blog site look this good, I'd be appreciative.

Reply

How did you make your site look this cool!? Email me if you can and share your wisdom. I'd appreciate it!

Reply

This website is extremely good! How was it made !

Reply

I adore that blog site layout . How do you make it. It's very cool!

Reply

Wow. This website is awesome! How did you  make it look like this !?

Reply

This website has got a lot of extremely helpful info on it! Thanks for informing me.

Reply

Have you considered adding some relevant links to the article? I think it might enhance my understanding.

Reply

How did you make your blog look this awesome!? Email me if you get the chance and share your wisdom. I'd be appreciative.

Reply

I like that blog layout . How was it made!? It is very nice.

Reply

I'm getting a javascript error, is anyone else?

Reply

Just discovered this blog through Yahoo, what a pleasant shock!

Reply

How did you make a site look this awesome! Email me if you get the chance and share your wisdom. I'd be thankful.

Reply

How did you make your blog site look this sick. Email me if you get the chance and share your wisdom. I'd be appreciative.

Reply

Have you considered adding some differing opinions to the article? I think it might enhance everyone's understanding.

Reply

The scornful nostril and the high head gather not the odors that lie on the track of truth.   -   George Eliot

Reply

I mean, nice article. Where is your rss?

Reply

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading