Search code examples
c#asp.netasp.net-mvc-4membership-providerparallels

Authentication not working on hosting


I've made a web-site, on Asp.net mvc4 / c# The site has /admin part for management. To access admin part, user is redirected to login page first. I've re-defined Membership provider to use hardcoded password, as I am the only admin on this site.

public override bool ValidateUser(String username, String 
{           
  return (username == "xxxx" && password == "xxxx");
}

In web-config, I've added this lines:

<authentication mode="Forms">
<forms loginUrl="~/Admin/User/LogIn" timeout="2880" />
</authentication>
<membership defaultProvider="CustomMembershipProvider">
  <providers>
    <clear />
   <add name="CustomMembershipProvider" type="CustomMembershipProvider" />
 </providers>
</membership>

And with all this everything is working locally. Login page is shown, I enter my login/pass and enter admin part.

Then I've deployed my site on a hosting where I have access through plesk parallels. And now when I am trying to visit admin page, instead of my page I receive a popup which is requiring login/pas of my hosting's user. After entering it a am redirected to admin page without visiting login page.

What I did wrong? What should be done to use my site's user and login page instead of my hosting's user/pas?


Solution

  • It was my mistake, not the hosting's problem. It occured that I've set [Authorize] attribute to whole User Controller. My Login Action is inside this controller, so when I try to access admin part I am redirected to User controller, but it also request authorization, and this problem occurs. I've removed Authorize attribute and now everytings is ok.