C# - Custom MembershipProvider Attempts To Pass Empty Creds After IIS Restart
Mar 12, 2010
I have a C# custom ASP.Net MembershipProvider. When the user attempts to navigate to another part of the site after IIS is restarted, it doesn't navigate to the login page to collect credentials, but instead attempts to authenticate with empty credentials.
what I have to do to identify that the new authentication needs to take place and that new creds need to be gathered?
I have a complementary custom IHttpModule implementation that allows me to intercept events like BeginRequest and AuthenticateRequest, if that helps.
I've recently started tinkering with ASP.NET MVC, but this question should apply to classic ASP.NET as well. For what it's worth, I don't know very much about forms authentication and membership providers either.
I'm trying to write my own MembershipProvider which will be connected to my own custom user table in my database. My user table contains all of the basic user information such as usernames, passwords, password salts, e-mail addresses and so on, but also information such as first name, last name and country of residence.
As far as I understand, the standard way of doing this in ASP.NET is to create a user table without the extra information and then a "profile" table with the extra information. However, this doesn't sound very good to me, because whenever I need to access that extra information I would have to make one extra database query to get it.
I read in the book "Pro ASP.NET 3.5 in C# 2008" that having a separate table for the profiles is not a very good idea if you need to access the profile table a lot and have many different pages in your website.
Now for the problem at hand... As I said, I'm writing my own custom MembershipProvider subclass and it's going pretty well so far, but now I've come to realize that the CreateUser doesn't allow me to create users in the way I'd like. The method only takes a fixed number of arguments and first name, last name and country of residence are not part of them.
So how would I create an entry for the new user in my custom table without this information at hand in CreateUser of my MembershipProvider?
I'm working on an ASP.NET solution with 2 projects. One is the web interface and the other contains my business logic. I'm using LINQ to SQL for my data access in the second project.
Apart of my database, I have a table called Users which holds user information.
I've started to implement a MembershipProvider. I notice that MembershipUser is coupled with MembershipProvider. What is the most correct way of getting my BLL/DAL to talk about Users? Should I minimally implement MembershipUser and whenever a user calls a method, it will call for eg. GetUserInfo() in my BLL/DAL, to get complete information about the user?
Or should I make the MembershipUser class methods call my custom "Users" class methods (like a wrapper) in the BLL/DAL (this custom users class is not related to linq)?
Or can I somehow extend the Linq to sql class "CFUsers" to extend MembershipUser.
I try to implement a Custom MembershipPriver with a Custom MemberShipUser in my own database (with a specifics Users Table Model) : This is ly diffent files:
iTwitterMembershipProvider.cs using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Security; using System.Collections.Specialized; using iTwitter.Models; public class iTwitterMembershipProvider : MembershipProvider { public override string ApplicationName { get { return _ApplicationName; } set { _ApplicationName = value; } } public override bool ChangePassword(string username, string oldPassword, string newPassword) { throw new NotImplementedException(); } public override bool ChangePasswordQuestionAndAnswer(string username, string password, string newPasswordQuestion, string newPasswordAnswer) { return false; } public override iTwitterMembershipUser CreateUser(string login, string password, string email, string tokenKey, string tokenSecret, string twitterUserId, object providerUserKey, out MembershipCreateStatus status) { ValidatePasswordEventArgs args = new ValidatePasswordEventArgs(login, password, true);
I have created a custom MembershipProvider and RoleProvider which communications with some existing business logic. The issue I have is that the user login in my business logic requires 3 arguments (group id, user id, and password) and the MembershipProvider and RoleProvider I implemented just use 1 or 2 arguments (username, password). Right now I append my group id and user id together and pass it as the username then parse it in the implemented methods. Is there a better way to do this?
Note, I can handle the login fine because I can call my own ValidateUser method. The main issue is when the implemented methods are called from other things like the RoleProvider.GetRolesForUser(username) method when I use the AuthorizeAttribute.
I created a custom membership provider and am getting the following error trying to create a new "MembershipUser".
Could not load type 'MyTestApp.Membership.TestMembershipProvider' from assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
I am running this from a Unit Test project, so I'm not sure if that's causing the issue, but I did include System.Web, System.Web.ApplicationServices as well as a reference to MyApp.Membership and MyApp.DataModels (Entity objects).
The error happens inside my "GetUser" function which is below, my configuration is also below.
I want to save some info in the Session when the users successfully logins with my custom MembershipProvider, but I have no access to the Session in the provider's ValidateUser method.
public class CustomMembershipProvider : MembershipProvider { /* Override other methods and properties here */ public override bool ValidateUser(string username, string password) { /* do something to validate the username and password * and set the validUser variable */ if (validUser) { /* want to store some info in the Session here, but I can't access * it here, because this is not a Page */ } return validUser; } }
I have written an assembly (DLL) containing two classes, MyMembershipProvider and MyRoleProvider, which are derived from MembershipProvider and RoleProvider, respectively. I have implemented most but not all of the abstract methods; the remaining ones all throw a NotImplementedException. I have signed the assembly and added a reference to it in my web-site project, where the relevant web.config sections look like this:
[Code]....
When I fire up the site, however, I get the following error:
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: Exception has been thrown by the target of an invocation.
The error message points to the <add /> tag in the <roleManager /> section: if I take that out, however (enabled="false"), it comes back again as soon as I try to log-in to the site (this time pointing to the membership section). I have verified that is recognising the classes by changing the name in the "type" attribute (to something that doesn't exist), at which point it throws a different error. Therefore I'm presuming there's a problem with my assembly code somewhere; but how can I find out where? I have debug=true in the web.config and also compiled the assembly with Debug options, but no clues.
I'm facing very odd problem with my application. I've been developing my own custom memberhip provider (derived from MembershipProvider, of course) and everything was working smoothly, until something odd happened. In my config file, I register my provider with such code:
[Code]....
When I deploy my site, I get this error message:
Configuration Error
Description:
An error occurred during the processing of a configuration file required to service this request. review the specific error details below and modify your configuration file appropriately.
Parser Error Message: Input string was not in a correct format.
Source Error:
Line 62: <clear/> Line 63: <add name="CustomSqlMembershipProvider" Line 64: type="My_Membership.CustomSqlMembershipProvider" Line 65: applicationName="My Application" Line 66: enablePasswordRetrieval="false"
I have a custom control that I have created. I want to be able to pass in a Javascript snippet for a callback function. I am able to do this by passing a string back. The problem is that in the Javascript, I need to reference another server control that is not related to my custom control. So, I need to be able to pass in the ClientID of that control for use in the Javascript. Here is a snippet of what I am trying to do:
[Code]....
Now, I realize that '<%= chkStartDate.ClientID %>' will not be parsed. But, I need it to be parsed so the OnClientOnChangeEvent property of my custom control can take any Javascript for use as a callback. In this instance, I need to pass in the ClientID of the control for the Javascript function to find the control to work with; and this seems to be the one issue that I don't know how to handle.
i have textbox whose value converted to Int32. while passing value to database when textbox is blank it gives error as Input string was not in a correct format.
ClassA is a custom class generated from a "type" in oracle database. ClassB is a custom class generated from a "table of type ClassA" in Oracle database.
The exposed service includes a login procedure which gets a username as input parameter and returns object B. Debugging the login procedure I can see that the data is retrieved from the database but not printed in the wsdl..
[Code]....
My ClassB definition is as follows:
[XmlInclude(typeof(ClassB))] public class ClassB : INullable, IOracleCustomType, IXmlSerializable ...
similar definition holds for ClassA as well. the generated wsdl is :
<? xml version="1.0" encoding="utf-8" ?> <ClassB xmlns="http://tempuri/org" />
In any event I override I don't have any attributes in my "base.Attributes or this.Attributes" collection. How's that possible? The rendered output clearly shows an id and an href attribute.
I'm trying to get rid of the href part and put in my own. Unfortunately Attributes.Remove("href") won't work.. because there's no such attribute. Or any attribute for that matter.
I have a custom control that has a hidden field. Upon postback I want to obtain the value stored in it, but it's always an empty string.I am performing client-side manipulation of the hidden field values and have verified in firebug that the fields are correct before issue a post back,Here is the setup:
public class DualListPanel : SWebControl, INamingContainer
I have created a VS 2008 web setup project with a dialog so that I can modify the web.config file at install. The setup worked as expected. However, I can not seem to accept a URL for a property value via custom data. I know directories are escaped with "", is there any similar escaping or tricks for a URL.
I am creating a new application..I created a login page successfully..Now I need to modify the login page ..Only 3 attempts only allowed for a user ..If the user wrongly enters the password more than 3 times(within 5 min) his account must be blocked..And error message must be shown as You cant access your page.
void Application_Start(object sender, EventArgs e) { RegisterRoutes(RouteTable.Routes); } public static void RegisterRoutes(RouteCollection routes) { routes.Add("BikeSaleRoute", new Route ( "bikes/sale", new CustomRouteHandler("~/Details.aspx") )); }
here when we type eg:[URL] it go to details.aspx now i want instead of bikes/sale that define here it read Behcode column from DB and when my user type their becode like this [URL] it go to details.aspx
This may be elementary user control stuff, but I can't get it to work.
How can I pass the Membership.GetUser.UserName variable (or any variable) through a user control parameter at load time?
[Code]....
The only thing that I was able to do was to create the User Control object in the code behind and then add it to the page. Although that works, it doesn't seem like the correct way to program.
My custome ControllerFactory controllerName is passed an Action name and not the only Controller in my application. Where or how can I correct this so my Controller name, SearchMembers, is passed in and not the Action name of that method, Search.
We have a handler to deal with .dat files.. everything is already setup and server is acknowledging the file type and doing its thing to handle it..
But the handler requires 1 bit of information along with the HTTP request which is a physical file path.. the file name it knows based on the file we call , but how can i pass a custom header along with the request so that the handler will use that when the request is made?
Basically when on our player.aspx page, i will have a button, when you click that button a request is made to the .dat file, but along with that request i need to send the physical file path.. how can i do that?
Language-Asp.net(c#) 2008 Sql Server 2005 well i designed a simple login form which checks the user and password with sql server but now i want to make it a little bit more secured basically i want if a user attempts wrong password with more then 3 /5 times. his id or username should be locked(which i will be running a update procedure) or he must be redirect to denied.htm and one more thing he should be able to get only n only 3/5 attempts whether he opens firefox browser,internet explorer ,safari,google chrome or any other browser