0

I have just added Package from NuGet called "ASP.NET Web Helpers Library 2.0.20710.1"(Install-Package microsoft-web-helpers) in my Visual Studio 2010(MVC3, C#).I install this to use WebGrid in my application. When I run the project I got the error: The connection name 'ApplicationServices' was not found in the applications configuration or the connection string is empty.

Again I am getting blue wavy line in all aspx and ascx pages in declaration of <%@ Control %> and <%@ Page %>

Web.config file content:

<?xml version="1.0"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=152368
  -->

<configuration>
  <connectionStrings>

    <add name="connect_str" connectionString="Data Source=APRICA-SERVER\SQLEXPRESS;Initial Catalog=CRM;User ID=sa"/>

  </connectionStrings>

  <appSettings>
    <add key="webpages:Version" value="1.0.0.0"/>
    <add key="ClientValidationEnabled" value="true"/>
    <add key="UnobtrusiveJavaScriptEnabled" value="true"/>
  </appSettings>

  <system.web>
    <compilation debug="true" targetFramework="4.0">
      <assemblies>
        <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      </assemblies>
    </compilation>

    <authentication mode="Forms">
      <forms loginUrl="~/Account/LogOn" timeout="2880" />
    </authentication>

    <membership>
      <providers>
        <clear/>
        <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices"
             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="ApplicationServices" applicationName="/" />
      </providers>
    </profile>

    <roleManager enabled="false">
      <providers>
        <clear/>
        <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
        <add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
      </providers>
    </roleManager>

    <pages>
      <namespaces>
        <add namespace="System.Web.Helpers" />
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Routing" />
        <add namespace="System.Web.WebPages"/>
      </namespaces>
    </pages>
  </system.web>

  <system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="WebServiceFetchFromOldDbSoap" closeTimeout="00:01:00"
          openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
          allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
          maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
          messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
          useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None"
              realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost:3880/WebServiceFetchFromOldDb.asmx"
        binding="basicHttpBinding" bindingConfiguration="WebServiceFetchFromOldDbSoap"
        contract="ServiceReferenceOLDDB.WebServiceFetchFromOldDbSoap"
        name="WebServiceFetchFromOldDbSoap" />
    </client>
  </system.serviceModel>
</configuration>
Dhwani
  • 7,484
  • 17
  • 78
  • 139
  • Can you post the connection strings section in your web.config? Clearly as the error states, the library you downloaded expects a connection string named "ApplicationServices" in the web.config.. – tranceporter Jan 31 '13 at 11:37

2 Answers2

4

Your problem is the membership section in web.config. The ASP.NET configuration tool uses "ApplicationServices" by default. If you change it to use "connect_str" connection string, it should work fine. Replace connectionStringName="ApplicationServices" with connectionStringName="connect_str" as shown below. The same goes for Profile and RoleManager.

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

As for the other issue, change the key under AppSettings:

<add key="webpages:Version" value="1.0.0.0"/>

to

<add key="webpages:Version" value="2.0.0.0"/>
tranceporter
  • 2,241
  • 1
  • 21
  • 23
  • I have changed connection string to "connect_str". In all place where connection string is "ApplicationServices ". But now I am getting different error. "Conflicting versions of ASP.NET Web Pages detected: specified version is "1.0.0.0", but the version in bin is "2.0.0.0". To continue, remove files from the application's bin directory or remove the version specification in web.config." – Dhwani Jan 31 '13 at 11:50
1

I think you either forgot to write a connection string in "Application Configuration". Or your connection string has difference name.

Look, you have mentioned your Connection string name ="connect_str" change it to ApplicationServices or vice versa..

Sakthivel
  • 1,890
  • 2
  • 21
  • 47
  • I have changed connection string to "connect_str". In all place where connection string is "ApplicationServices ". But now I am getting different error. **"Conflicting versions of ASP.NET Web Pages detected: specified version is "1.0.0.0", but the version in bin is "2.0.0.0". To continue, remove files from the application's bin directory or remove the version specification in web.config."** – Dhwani Jan 31 '13 at 11:47