views:

70

answers:

2

Hello SO:

I just uploaded an MVC application to my live server. Before doing so, I created a user ('anders') after creating the necessary tables and stored procedures for authentication via the aspnet_regsql command in the VS2008 Command Prompt. I successfully tested, locally, that I need to log in before (or while) accessing this view:

[Authorize(Roles = "admin")]
public ViewResult Index()
{
    return View();
}

I made a back up of my local database, and restored this to my live server. Before testing the view, I verified that I can log in with my newly-created user. However, when I try to access the view after logging in, I get redirected indefinitely to the log in page.

New Info

Looks like something else is going on, but the above information may still be useful. Apparently my user is not in the admin group, even though I looked into the database and verified that my UserID is in the dbo.aspnet_Roles table and the RoleID corresponds with the admin role. I found this out by changing the code at the top of the master page where it welcomes the logged in user, and noticed that it returned false:

Welcome <b><%= Html.Encode(Page.User.Identity.Name) %></b>!
(<%= Html.Encode(Page.User.IsInRole("admin")) %>)

Both my user and the newly created 'stackoverflow' (password is passw0rd, for you guys to check it out) user are supposed to be in the admin role, but for some reason they are not.

Any help with tracking down the reason why my users aren't being recognized as being in the 'admin' role would be greatly appreciated. Thanks in advanced!

Link to my live server.

+1  A: 

Are you using any caching technique ? this maybe the reason.

also you need to verify that the RoleProvider is working, but without more details I cant help more

Ahmed Khalaf
Alright. What more information can I post to help you out? Also, how can I verify that the RoleProvider is working? I have not implemented a custom one.
Anders
Figured it out, the default RoleProvider was mapped to a local database. Tweaked some settings in the web.config got things working properly. Thanks for the hint, it probably saved me a good deal of time!
Anders
Here u're some points to check.1- Make sure your Web.Config is using correct settings2- You can put a diagnostics page that display providers working3- You can run your locally hosted code, with connection string to the remote database server.4- Default RoleProvider needs a database, Make sure that you have accecss to it, it maybe a hosting limitation.
Ahmed Khalaf
Seems we were writing at the same time :D, anytime.
Ahmed Khalaf
A: 

I was having the same Issue. In web.config:

<roleManager enabled="true">
...

Was set to false at server's config but not local's.

ppvi