mugsey
asked on
FormsAuthentication.RedirectFromLoginPage not working
ASP.NET app working fine locally using memberhip provider and in code I authenticate at login
FormsAuthentication.Redire ctFromLogi nPage..... .......
Works great. But if I put on test server I get authenticaion error "unkown user" . It is using the same database so the user is there.
However I ripped out the code and used a login control and it works fine on both local and test servers.
My question is why? I want to use
FormsAuthentication.Redire ctFromLogi nPage in code
FormsAuthentication.Redire
Works great. But if I put on test server I get authenticaion error "unkown user" . It is using the same database so the user is there.
However I ripped out the code and used a login control and it works fine on both local and test servers.
My question is why? I want to use
FormsAuthentication.Redire
ASKER
HI guru sami
It is standard web.config stuff for membership.
It actually fails on this login code
var user = UserService.GetUserByUsern ame(userna me.Text);
It works fine on my local pc and dev server BUT it does not work on the dev server if it returns null.
So if I put in wrong username it works fine locally but for some reason it errors saying unkown user on dev server
It is standard web.config stuff for membership.
It actually fails on this login code
var user = UserService.GetUserByUsern
It works fine on my local pc and dev server BUT it does not work on the dev server if it returns null.
So if I put in wrong username it works fine locally but for some reason it errors saying unkown user on dev server
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
HI Yes
It is using custom membership provider that inherits from standard membership.
Username exists in database but I was testing for null user, ie, putting in wrong username
So if I put in wrong username on local PC it works fine handling null value returned but on dev server looking at the SAME database I get the same exepected behaviour unkown user but it throws an authentication exception "unkown user"
So I think my question is why is that if I can return NULL to
var user = UserService.GetUserByUsern ame(userna me.Text);
which works fine on my local PC
but if I return NULL to
var user = UserService.GetUserByUsern ame(userna me.Text);
I get unhandled exception "Uknown user" - on the dev server it cannot seem to handle having a null passed to var user =
It is using custom membership provider that inherits from standard membership.
Username exists in database but I was testing for null user, ie, putting in wrong username
So if I put in wrong username on local PC it works fine handling null value returned but on dev server looking at the SAME database I get the same exepected behaviour unkown user but it throws an authentication exception "unkown user"
So I think my question is why is that if I can return NULL to
var user = UserService.GetUserByUsern
which works fine on my local PC
but if I return NULL to
var user = UserService.GetUserByUsern
I get unhandled exception "Uknown user" - on the dev server it cannot seem to handle having a null passed to var user =
hmmm nothing else poping up ... can you try returning an empty string or empty object from GetUserByUsername instead of null if user is not found and see what the code does?
Forgive my ignorance but is the function GetUserByUsername not expecting a valid/existing username?
Is that your custom error message or system generated?
Can you post the code you use for authentication and web.config.