Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 4.5 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4.5: in C# and VB by Imar Spaanjaars; ISBN: 978-1-118-31180-6
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4.5 : in C# and VB section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 16th, 2015, 06:33 PM
Authorized User
 
Join Date: Aug 2014
Posts: 34
Thanks: 3
Thanked 0 Times in 0 Posts
Default Unable to log in - Web.config

Hi and TIA:

After being able to run my program on the development machine, I have essentially uploaded all files (aspx., and database) successfully to my web server.

The problem is I cannot login anymore?
Would you please look at my web.config file and see if you see anything blatantly wrong. Thanks

P.S. The <providers> section in <entityFramework> (at the bottom of code) seems "unhappy" and requests <contexts> instead. Could this be the problem?

Code:
<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
  </configSections>
  <connectionStrings>
    <add name="GolfDatabaseConnectionString1" connectionString="Data Source=esherr01.db.8004918.hostedresource.com;Initial Catalog=esherr01;User ID=esherr01; Password='xxxxxx';Integrated Security=True;MultipleActiveResultSets=True;Application Name=EntityFramework"
      providerName="System.Data.SqlClient" />
   <add name="GolfDatabaseEntities10" connectionString="metadata=res://*/App_Code.GolfHandicap.csdl|res://*/App_Code.GolfHandicap.ssdl|res://*/App_Code.GolfHandicap.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=esherr01.db.8004918.hostedresource.com;Initial Catalog=esherr01;User ID=esherr01; Password='xxxxxx';integrated security=True;multipleactiveresultsets=True;application name=EntityFramework&quot;"
      providerName="System.Data.EntityClient" />
    <add name="GolfDatabaseConnectionString2" connectionString="Data Source=esherr01.db.8004918.hostedresource.com;Initial Catalog=esherr01;User ID=esherr01; Password='xxxxxx';Integrated Security=True;MultipleActiveResultSets=True;Application Name=EntityFramework"
      providerName="System.Data.SqlClient" />
  </connectionStrings>
  <appSettings>
       <add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
       <add key="autoFormsAuthentication" value="false" />
       <add key="enableSimpleMembership" value="false"/>
   </appSettings>
  <system.web>
    <trust level="Full" />
    <trace mostRecent="true" enabled="true" requestLimit="1000" pageOutput="false" localOnly="true" />
    <customErrors mode="Off">
    </customErrors>
    <authentication mode="Forms">
      <forms timeout="1440"/>
    </authentication>
    <!--<authorization>
      <deny users="?" /> 
    </authorization> -->
    <pages theme="DarkGrey">
      <controls>
        <add tagPrefix="ajaxToolkit" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" />
      </controls>
    </pages>
    <compilation debug="false" targetFramework="4.5">
     <assemblies>
        <add assembly="System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
        <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
        <add assembly="System.Data.Entity.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
        <add assembly="System.Data.Services.Client, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
      </assemblies>
      <buildProviders>
        <add extension=".edmx" type="System.Data.Entity.Design.AspNet.EntityDesignerBuildProvider" />
      </buildProviders>
    </compilation>
    <httpRuntime targetFramework="4.5" />
    <profile defaultProvider="DefaultProfileProvider">
      <providers>
        <add name="DefaultProfileProvider" type="System.Web.Providers.DefaultProfileProvider, System.Web.Providers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="GolfDatabaseConnectionString1" applicationName="/" />
      </providers>
    </profile>
    <membership defaultProvider="DefaultMembershipProvider">
      <providers>
	<clear />
        <add name="DefaultMembershipProvider"
             type="System.Web.Providers.DefaultMembershipProvider, 
             System.Web.Providers, Version=2.0.0.0, Culture=neutral,
             PublicKeyToken=31bf3856ad364e35"
             connectionStringName="GolfDatabaseConnectionString1" 
             enablePasswordRetrieval="false" 
             enablePasswordReset="true" 
             requiresQuestionAndAnswer="false"
             requiresUniqueEmail="false" 
             maxInvalidPasswordAttempts="5" 
             minRequiredPasswordLength="6" 
             minRequiredNonalphanumericCharacters="0" 
             passwordAttemptWindow="10" 
             applicationName="/" />
      </providers>
    </membership>
    <roleManager defaultProvider="DefaultRoleProvider">
      <providers>
        <add name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="GolfDatabaseConnectionString1" applicationName="/" />
      </providers>
    </roleManager>
    <!--
            If you are deploying to a cloud environment that has multiple web server instances,
            you should change session state mode from "InProc" to "Custom". In addition,
            change the connection string named "DefaultConnection" to connect to an instance
            of SQL Server (including SQL Azure and SQL  Compact) instead of to SQL Server Express.
      -->
    <sessionState mode="InProc" customProvider="DefaultSessionProvider">
      <providers>
        <add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="GolfDatabaseConnectionString1" />
      </providers>
    </sessionState>
  </system.web>
  <system.webServer>
    <defaultDocument>
      <files>
        <clear />
        <add value="index.html" />
      </files>
    </defaultDocument>
  </system.webServer>
  <system.net>
    <mailSettings>
      <smtp deliveryMethod="Network" from="Cliff Sherrill &lt;ssezotman@gmail.com &gt;">
        <network enableSsl="true" host="smtp.gmail.com" userName="ssezotman@gmail.com" password="Bond007cliff49" port="587" />
      </smtp>
    </mailSettings>
  </system.net>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="v12.0" />
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
</configuration>
 
Old April 17th, 2015, 03:48 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

This looks fine to me, assuming your user name and password are OK. Try removing the MultipleActiveResultSets and Application Name items from GolfDatabaseConnectionString1 although that shouldn't matter.

Do you get an error when you try to log in?

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old April 17th, 2015, 03:59 PM
Authorized User
 
Join Date: Aug 2014
Posts: 34
Thanks: 3
Thanked 0 Times in 0 Posts
Default Trouble logging in to remote server

Hi:
Yes I do get an error when I try to log into my remote web server from my login page.

Server Error in '/' Application.
Login failed for user 'PHX3\Iusr_8004918'.


(I believe the above references where the database resides.

It also talks some about "Provider Incompatible Exception"?

I removed MultipleActiveResultSets and Application Name with no change.

Sorry, fairly stumped
 
Old April 19th, 2015, 04:16 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Ah, that explains it. Your connection strings have this:

Integrated Security=True

which means it'll use the account used to run the site. This will ignore your user name and password in the connection strings.

Remove Integrated Security=True from all three connection strings to make it work.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old April 19th, 2015, 05:14 PM
Authorized User
 
Join Date: Aug 2014
Posts: 34
Thanks: 3
Thanked 0 Times in 0 Posts
Default New error message

Hi:

I deleted the Integrated Security = True from all three connectionstrings and now I am able to login to my site.

But as soon as I click a menu item having to do with a need to access the database I get, "Format of the initialization string does not conform to specification starting at index 144."

I've done some Googling for this error and everyone seems to point to an error in the connectionstring section of the web.config. Below is a copy of my new connectionstring.

Code:
<connectionStrings>
    <add name="GolfDatabaseConnectionString1" connectionString="Data Source=esherr01.db.8004918.hostedresource.com;Initial Catalog=esherr01;User ID=esherr01; Password='xxxxxx'"
      providerName="System.Data.SqlClient" />
   <add name="GolfDatabaseEntities10" connectionString="metadata=res://*/App_Code.GolfHandicap.csdl|res://*/App_Code.GolfHandicap.ssdl|res://*/App_Code.GolfHandicap.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=esherr01.db.8004918.hostedresource.com;Initial Catalog=esherr01;User ID=esherr01; Password='xxxxxx'"
      providerName="System.Data.EntityClient" />
    <add name="GolfDatabaseConnectionString2" connectionString="Data Source=esherr01.db.8004918.hostedresource.com;Initial Catalog=esherr01;User ID=esherr01; Password='xxxxxx'"
      providerName="System.Data.SqlClient" />
  </connectionStrings>
Good news is that we are making some progress with a new error and I am able to login.

Thanks for looking a this
Cliff

Last edited by ssezotman; April 19th, 2015 at 05:34 PM..
 
Old April 20th, 2015, 11:32 AM
Authorized User
 
Join Date: Aug 2014
Posts: 34
Thanks: 3
Thanked 0 Times in 0 Posts
Default Further Clues

Hi:

I can now use the login control on my login page and access my web server.

In my web.config I changed compile debug to true to look at any further error clues.

After logging in I get my default.aspx page just fine and I can also go to my contact.aspx page. Note that neither of these access my database.

But if I try (via menu on left side) to access a link which requires access to my database I get the following error.

Format of the initialization string does not conform to specification starting at index 144.

I am also given the following source error:

/// Initializes a new GolfDatabaseEntities10 object using the connection string found in the 'GolfDatabaseEntities10' section of the application configuration file.
Line 40: /// </summary>
Line 41: public GolfDatabaseEntities10() : base("name=GolfDatabaseEntities10", "GolfDatabaseEntities10")
Line 42: {
Line 43: this.ContextOptions.LazyLoadingEnabled = true;


Source File: d:\hosting\8004918\html\App_Code\GolfHandicap.Desi gner.cs Line: 41


Interesting that I have never changed this file at all, knowing that it has been created in the background. Still it references my Entities and thus my thought is that the trouble continues to lie with the Entities connection string in my web.config file. Here it is:

<add name="GolfDatabaseEntities10" connectionString="metadata=res://*/App_Code.GolfHandicap.csdl|res://*/App_Code.GolfHandicap.ssdl|res://*/App_Code.GolfHandicap.msl;provider=System.Data.Sql Client;provider connection string=&quot;Data Source=esherr01.db.8004918.hostedresource.com;Init ial Catalog=esherr01;User ID=esherr01; Password=xxxxxx"
providerName="System.Data.EntityClient" />


Thanks for looking
Cliff
 
Old April 20th, 2015, 02:19 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

You seem to be missing a closing &quot; and MultipleActiveResultSets=True;App=EntityFramework in the inner connection string (which you may have removed when you took out the app name earlier). For reference, here's the one from the Planet Wrox site:

<add name="PlanetWroxEntities" connectionString="metadata=res://*/App_Code.PlanetWrox.csdl|res://*/App_Code.PlanetWrox.ssdl|res://*/App_Code.PlanetWrox.msl;provider=System.Data.SqlCl ient;provider connection string=&quot;data source=(LocalDB)\v11.0;attachdbfilename=|DataDirec tory|\PlanetWrox.mdf;integrated security=True;MultipleActiveResultSets=True;App=En tityFramework&quot;" providerName="System.Data.EntityClient" />

Just replace PlanetWrox with GolfDatabase (and add the number 10). Then paste both connection strings in notepad each on a line and fine the differences.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old April 20th, 2015, 02:22 PM
Authorized User
 
Join Date: Aug 2014
Posts: 34
Thanks: 3
Thanked 0 Times in 0 Posts
Default csdl, ssdl and msl files

Hi again:

As I work on the connectionStrings area I have begun looking at the 3 metadata files that are listed:

App_Code.GolfHandicap.csdl
App_Code.GolfHandicap.ssdl
App_Code.GolfHandicap.msl

Do I need to upload these files to my remote web server? If so. which folder should I place them?

On my development machine they are in: C:\Windows\Microsoft.NET\\Framework\v4.0.30319\Tem porary ASPNET Files\root\3bcf970a\8fdf76\16\ResX

Thanks for all the help
Cliff
 
Old April 20th, 2015, 02:32 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Nope, those are created from the edmx file.

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old April 20th, 2015, 03:24 PM
Authorized User
 
Join Date: Aug 2014
Posts: 34
Thanks: 3
Thanked 0 Times in 0 Posts
Default Pretty much same error

Hi

My new Entitues connection string:

<add name="GolfDatabaseEntities10" connectionString="metadata=res://*/App_Code.GolfHandicap.csdl|res://*/App_Code.GolfHandicap.ssdl|res://*/App_Code.GolfHandicap.msl;
provider=System.Data.SqlClient;provider connection string=&quot;Data Source=esherr01.db.8004918.hostedresource.com;
Initial Catalog=esherr01;User ID=esherr01; Password='xxxxxx';
attachdbfilename=|DataDirectory|\GolfDatabase.mdf; MultipleActiveResultSets=True;App=EntityFramework"
providerName="System.Data.EntityClient" />


I left out the Integrated Secureity - true as per a previous post.

I'm still getting the following:

Format of the initialization string does not conform to specification starting at index 152, and

Line 39: /// Initializes a new GolfDatabaseEntities10 object using the connection string found in the 'GolfDatabaseEntities10' section of the application configuration file.
Line 40: /// </summary>
Line 41: public GolfDatabaseEntities10() : base("name=GolfDatabaseEntities10", "GolfDatabaseEntities10")
Line 42: {
Line 43: this.ContextOptions.LazyLoadingEnabled = true;

I feel like I'm getting closer. Thanks so much!





Similar Threads
Thread Thread Starter Forum Replies Last Post
App.Config and Web.Config conflict John.Burke ASP.NET 2.0 Professional 5 March 9th, 2010 11:51 AM
Fix for Web.config Error in ...\Chapter01\LINQforBinding Web Sites rogerj BOOK: Professional ADO.NET 3.5 with LINQ and the Entity Framework ISBN: 978-0-470-22988-0 0 February 18th, 2009 01:59 PM
web.config vs. app.config darlo Visual Studio 2005 11 August 20th, 2008 07:23 AM
Unable to connect: incorrect log on parameters. Dmitriy ASP.NET 1.0 and 1.1 Professional 0 June 18th, 2007 07:53 AM
Unable to connect: incorrect log on parameters casjachan ASP.NET 1.x and 2.0 Application Design 2 July 25th, 2004 04:55 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.