I need to publish a demo website to the web. I need to secure access to the site.
The live site with use SQL Server as the membership provider. However, for the demo site I can only publish to a simple web host and have no access to SQL Server.
I need only a single user, and they don't need option to change password etc. Therefore, I thought easiest way to achieve this would be to use the member of within the web.config. I have created as follows:
<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<system.web>
<authentication mode="Forms">
<forms name="ProjectApple" loginUrl="~Login.aspx">
<credentials passwordFormat="Clear">
<user name="lawyer" password="Super12."/>
</credentials>
</forms>
</authentication>
<compilation debug="true"/>
</system.web>
</configuration>
I will use SHA1 hash when I can get this working. Problem is, it recognises when I've entered an invalid password. However, when I enter the correct password I get the following:
Cannot open user default database. Login failed.
Login failed for user 'RB-T510\Rob'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Cannot open user default database. Login failed.
Login failed for user 'RB-T510\Rob'.
I don't know why it's looking for SQL? Can anyone help please?
I'm using VS2010 and .Net 3.5
Many thanks,
Rob
To use forms authentication with credentials in web.config you must use FormsAuthentication.Authenitcate method. Looks like you have default Login control that is trying to access membership class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With