简体   繁体   中英

What is wrong with my web.config file and Role manager settings? IIS6.0 and SQL Server 2005 wont let me in

I have developed an application which works fine on my local IIS7 server. I can log into it using a different machine on the local network and access all areas.

After deploying it on an SBS2003 server with IIS6.0 and SQL Server 2005 I have had access problems. I have sorted this to the point where I can now load the web app and log in. The problem begins when I want to access a page that requires authentication. Even though I am logged in I cannot load the page. Needless to say that this applies to pages that requires RBA also.

The current error message I get is:

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

If you are going to answer this question by telling me the answer to the problem is in the error message then please first remember that I can log in to my application. I obviously have a connection to the DB. After that if the answer is still simple please feel free to mock me.

Here is my web.config:

<?xml version="1.0"?>

<configuration>
  <connectionStrings>
    <add name="ZenIntranetConnectionString" connectionString="Data Source=127.0.0.1;Database=ZenIntranet;Integrated Security=True;"
      providerName="System.Data.SqlClient" />
  </connectionStrings>

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
    <httpRuntime maxRequestLength="8192" executionTimeout="360"/>
    <authentication mode="Forms">
      <forms loginUrl="~/Account/Login.aspx" timeout="2880" />
    </authentication>

    <membership>
      <providers>
        <clear/>
        <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ZenIntranetConnectionString"
             enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false"
             maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
             applicationName="/" />
      </providers>
    </membership>

    <profile>
      <providers>
        <clear/>
        <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ZenIntranetConnectionString" applicationName="/"/>
      </providers>
    </profile>

    <roleManager enabled="true" defaultProvider="ZenRoleProvider">
      <providers>
        <clear/>
        <add name="ZenRoleProvider" type="BusinessClasses.ZenRoleProvider, BusinessClasses" 
        connectionStringName="ZenIntranetConnectionString"
            applicationName="/" />
      </providers>
    </roleManager>

  </system.web>

  <system.webServer>
     <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
</configuration>

Thanks for your help. I really really need it.

PS I only just added the connection string name in the <roleManager> tag. I've never needed it before and my local web.config doesnt seem to require it. I've left it in their for now because I've seen that others said it was necessary. Regardless, it doesn't work.

The problem was hard coded connection strings (generated by VS) used for the dataset designer in the dataclasses layer.

I could login ok because the home page didnt load any data objects but as soon as I needed something from the dataset.xsd file the application was using the hard coded connection string from the DAL (which still had my development server connection string). I found the strings after doing a solution wide search for connectionString .

On a side note, I thought that the web.config should over ride this but it doesnt.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM