6

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

4
  • Is it possible that the login is succeeding, but the next step (whatever page is opening) is attempting to execute sql? Could you post the rest of the web.config? Commented Mar 22, 2011 at 23:01
  • Do you still have the references to the Membership provider in your demo config? Commented Mar 22, 2011 at 23:25
  • 1
    I would post the whole config file and the whole stack trace. Commented Mar 22, 2011 at 23:32
  • It won't be too cumbersome if you want to write you own MembershipProvider which uses XML file as the datasource. You can add Username and Password field in XML file and just override the ValidateUser(username, password) method of the custom MembershipProvider. It won't be too hard to write your own MembershipProvider and the benefit of it is that you can reuse it in future too. Commented Mar 23, 2011 at 1:34

3 Answers 3

4

To use forms authentication with credentials in web.config you must use FormsAuthentication.Authenticate method. Looks like you have default Login control that is trying to access membership class.

Sign up to request clarification or add additional context in comments.

Comments

0

I am going to guess, based on the format of the user name in the error, that you still have a connection string in your web.config with Integrated Security=True and there is some control on the page that is opening that is requesting data from SQL.

Comments

-1

First Check out your Authentication mode. if SQLAuthentication, Give UserId,and Password in your Connection String. Example:

<"Data source="";Initial Catalog="Dbname";UserId=sa;Password=1234">

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.