When you are accessing SharePoint site anonymously, you can easily click on the Login link and based on your authentication type either you are prompted for credentials or will be redirected to the login page(if FBA authentication).
Let's say I have hardcoded the credentials in my code and want to do the same programmatically.
If I want to start from the beginning:
One of the SharePoint weakness is that you cant act for anonymous users, for instance you cant change or remove the permissions of a ListItem.
So I concluded that we have to use a user with as limited access as possible like Guest and when anonymous users in some specific page which has my Webpart in it, I hardcode credentials to login and redirect them to a page.
I know about impersonation and other stuff like it which is use in code behind world and it's not what i meant.
So the question is very simple, How Can I Do That?