1

Is it possible?

It means i hope to create the widget to paste it at different pages on a site(or even in the master mage) to give users ability to quick login. Is it possible or all pages when login accessable have to be enumerated like this:

<authentication mode="Forms">
      <forms loginUrl="~/Account/LogOn" timeout="2880" />
</authentication>
skaffman
  • 398,947
  • 96
  • 818
  • 769
  • Are you using Asp.Net (Web Forms) or MVC? Based on the Url I am guessing MVC, but I wanted to make sure. – Ethan Cabiac Jun 10 '11 at 17:27
  • Regardless of it value, in order to help answer your question I would like to know if you are using Web Forms or MVC. The code example provided above is an extensionless URL that is *typically* found in MVC Applications. – Ethan Cabiac Jun 13 '11 at 15:37

1 Answers1

1

As long as the page allows anonymous access, I don't see why this would be a problem. Just put a username/password field on the page and use the API to log them in:

if (Membership.ValidateUser(username, password))
{
    FormsAuthentication.SetAuthCookie(username, true / false);
}

EDIT: You probably want to SSL any page with a password field on it.

Greg
  • 16,540
  • 9
  • 51
  • 97
  • Thanks a lot, unfortunally i havn't enought reputation to vote up. The problem is that i thought that this is the url in web config *from those* cookie should be set. Stupid question as i understood now=) – Daniil Grudzinskiy Jun 16 '11 at 09:19
  • I see. The loginUrl should be set to a "default" Login page. If a user tries to access a restricted page, they'll be redirected to this page. – Greg Jun 16 '11 at 12:47