forms-authentication

Automatically sign out from Forms Authentication in ASP.NET when browser is closed

吃可爱长大的小学妹 提交于 2019-12-04 21:44:37
Is there a way to force ASP.NET to sign out from it's authentication when the browser is closed or the user types in a new address? If the browser is left open then I need to keep the user authenticated, so a long timeout on the authentication ticket is preferable. Not sure if this is still an issue but this resolved the issue for me. Just add the following to the Page_Load event of your Start Page: protected void Page_Load(object sender, EventArgs e) { if (Request.UrlReferrer == null || string.IsNullOrEmpty(Request.UrlReferrer.AbsolutePath)) { Session.Abandon(); FormsAuthentication.SignOut();

How do I add HTTPS to my asp.net website for account login?

我的未来我决定 提交于 2019-12-04 20:01:35
I have an ASP.NET MVC 3 web application using Forms Authentication. What are the basic steps I need to take to enable https for account logins? I'm using IIS 7.5 on Windows Server 2008 R2 All you need to do is get a certificate and install it in IIS, bind your host to port 443 and you should be good to go. Your app should run as-is on there. http://Startssl.com has free certificates that work very nicely and are recognized in all browsers. Good resource here To start, you need to get a certificate from a certificate authority. You will then have to import it to your server. At this point you

Why isn't .ASPAUX cookie being validated by FormsAuthentication?

亡梦爱人 提交于 2019-12-04 19:59:54
I have a site that uses FormsAuthentication and yes, the name of the cookie is .ASPAUX :) I can log in perfectly. The server creates a forms authentication ticket, packs it in a cookie, properly determines the expiration time (1 year ahead) and sends it to the client. For some reason, after some time, even though the cookie is there yet (I can see it with FireCookies) HttpContext.Current.Request.IsAuthenticated becomes false at the server. It's as if the cookie couldn't be validated. The problem is: Why would that happen? How can I debug why the cookie suddenly becomes invalid without expiring

FormsAuthentication - handling a change of username

陌路散爱 提交于 2019-12-04 18:33:28
问题 My ASP.NET MVC web application allows administrators to change their own, or other users' usernames. Users are logged in by calling FormsAuthentication.SetAuthCookie(userName [string], createPersistentCookie [bool]) . They are logged out by calling FormsAuthentication.SignOut() . I understand that after updating the username I'd need to sign them out and back in again. But how do I retrieve the existing value of createPersistentCookie ? e.g. how do I retain their original 'remember me'

How do I keep my Login.aspx page's ReturnUrl parameter from overriding my ASP.NET Login control's DestinationPageUrl property?

…衆ロ難τιáo~ 提交于 2019-12-04 17:43:34
问题 I'm using the ASP.NET Login Controls and Forms Authentication for membership/credentials for an ASP.NET web application. I've got pages such as PasswordRecovery.aspx that are accessable to only Anonymous users. When I click my login link from such a page, the login page has a ReturnUrl parameter in the address bar: http://www.example.com/Login.aspx?ReturnUrl=PasswordRecovery.aspx And then after a successful login, users are returned to the PasswordRecovery.aspx page specified in the ReturnUrl

How to use forms authentication without login control?

好久不见. 提交于 2019-12-04 17:43:00
How to use forms authentication without login control.I don't want to use asp.net login control in my site.But i have to implement forms authentication and to validate users in my database. I am assuming that instead of using a login control, you are using a few textboxes(eg username/password) and a logon button. The code could look something like this: In your aspx file <asp:Textbox runat="server" ID="Username"/> <asp:Textbox runat="server" ID="Password"/> <asp:Button runat="server" ID="Login" OnClick="Login_OnClick"/> <asp:Label runat="server" ID="Msg" > And on server side: public void Login

Custom Forms Authentication + MVC3 + AuthorizeAttribute

这一生的挚爱 提交于 2019-12-04 17:42:00
I am essentially doing is this . However, whenever I use the built in AuthorizeAttribute, the MVC framework (I'm guessing) never looks at my principal to determine if the user has the proper roles. It keeps trying to create a new MDF file in the app_data directory, and because it doesn't have privileged it blows up. Is this expected behavior, and should I derive my own AuthorizeAttribute and check the principal myself? Another weird behavior to point out is that I have two sites on the same domain for which I'm doing single sign on. On either site, I'm using the same class library to recreate

Detecting forms authentication timeout in login page

匆匆过客 提交于 2019-12-04 17:38:59
When you have forms authentication setup to redirect to login.aspx when accessing a protected page, what's a good way to detect in login.aspx whether the user was sent there because they haven't logged on yet, or because their forms auth ticket is expired? I'd like to display a "you've timed out" message. (I do not mention the word session in this question, because ASP.NET treats them so distinctly, however, if there is a good solution that involves session, I'm all ears) I've solved this in the past by having another cooke "hasloggedin" set when a user logs in and then checks to see if that

Something like an operation filter in WCF REST?

故事扮演 提交于 2019-12-04 16:45:46
I am looking for something like the AuthorizeAttribute in MVC, something I can use like this: [WebGet(UriTemplate = "data/{spageNumber}")] [WebCache(CacheProfileName = "SampleProfile")] [WcfAuthorize] public IEnumerable<SampleItem> GetCollection(String spageNumber) { Int32 itemsPerPage = 10; Int32 pageNumber = Int32.Parse(spageNumber); return Enumerable.Range(pageNumber * itemsPerPage, itemsPerPage) .Select(i => SampleItem.Create(i)); } That WcfAuthorizeAttribute , will try to authenticate the user with FormsAuthentication, and set the context's IPrincipal, or return a HTTP 401 Unauthorized. I

ASP.NET authentication cookies not stored when using jQueryMobile on iPad

六眼飞鱼酱① 提交于 2019-12-04 16:15:48
I have an ASP.NET MVC2 app using jQueryMobile. It is a secure app, and i'm using the ASP.NET authentication within the MVC2 framework. I am using standard authentication via the web.config: <authentication mode="Forms"> <forms loginUrl="~/Account/LogOn" timeout="2880" /> </authentication> I am securing certain controllers using the Authorize attribute: [Authorize] public class ClientController : Controller All my web pages as based upon the same master page, which has a top-level container div as follows: <div class="page" data-role="page"> It all works perfectly on Chrome. However, on the