Godaddy ASP.NET membership database woes - asp.net

I purchased a Windows shared hosting account on godaddy that came with 2 MSSQL databases. I setup one to hold my site data and the other installed aspnet membership schema to store site members. The site works perfectly even displaying data from the 1st database. However when I try to login or register I get this nasty error
Exception Details:
System.Configuration.Provider.ProviderException:
The SSE Provider did not find the
database file specified in the
connection string. At the configured
trust level (below High trust level),
the SSE provider can not automatically
create the database file.
Ive gone through my web.config and there's nothing wrong with my 2 connection strings. It seems godaddy has a problem with using 2 mssql databases simultaneously when 1 is for membership.
Does anyone know a solution or a workaround?

I hope my experience benefits every one. Basically if you want to avoid aspnet membership problems on godaddy always use "LocalSqlServer" as the connectionstring. i.e
<providers>
<remove name="AspNetSqlMembershipProvider" />
<add name="AspNetSqlMembershipProvider" connectionStringName="LocalSqlServer"
..other attributes here... />
</providers>
Then create the "LocalSqlServer" connectionString...remember to remove it first
<connectionStrings>
<remove name="LocalSqlServer"/>
<add name="LocalSqlServer"
connectionString="Data Source=xxxx; Initial Catalog=xxx; User ID=xxx; Password=xxx;"
providerName="System.Data.SqlClient" />
</connectionStrings>

I ran into same problem and am using MVC3. Above solution works but with some other changes in MVC3. It took me long time to figure it out so if anybody has similar issue in MVC3 it might help them:
Search for "connectionStringName" in web.config and replace the name with connectionStringName="LocalSqlServer"
Also under connectionstrings make sure
-To add (As this is important for all who are using shared hosting it will replace machine.config LocalSqlServer connectionstring with yours.)
-Keep your current connectionstring (In my case it is FilmiDb, this is required for you to connect to the database in EF model. Without this you will get errors.)
<connectionStrings>
<remove name ="LocalSqlServer"/>
<add name="LocalSqlServer" connectionString="Data Source=.\SQLExpress;Initial Catalog=SofilmiDb;Integrated Security=SSPI" providerName="System.Data.SqlClient" />
<add name="FilmiDb" connectionString="Data Source=.\SQLExpress;Initial Catalog=FilmiDb;Integrated Security=SSPI" providerName="System.Data.SqlClient" />
</connectionStrings>

Related

ASP.NET Identity - where my tables created?

I have created sample register page to create user using ASP.NET Identity. Actually, I am working with this project since long back; which means, database is already existing.
From Register.aspx page, when clicked on the Register button, getting the message like "User created successfully"; but could not able to find out where relevant tables created.
Below is the connectionstrings section of my web.config file. Please note that, second connectionString "LocalDBConnectionString" is existing but NOT using anywhere, and in-fact not working.
I have verified with all the relevant databases for membership tables, but could not find relevant one.
<connectionStrings>
<add name="ASHOKConnectionString" connectionString="Data Source=SHRESTASOFT\SQLEXPRESS;Initial Catalog=ASHOK;Persist Security Info=True;User ID=sa; Password=tentod" />
<add name="LocalDBConnectionString" connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\ClassDB.mdf;Integrated Security=True" />
<add name="ASHOKEntities" connectionString="metadata=res://*/EntityFramework.ASHOK.csdl|res://*/EntityFramework.ASHOK.ssdl|res://*/EntityFramework.ASHOK.msl;provider=System.Data.SqlClient;provider connection string="data source=SHRESTASOFT\SQLEXPRESS;initial catalog=ASHOK;persist security info=True;user id=sa;password=tentod;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
<add name="NORTHWINDDataContext" connectionString="metadata=res://*/EntityFramework.NorthwindDataContext.csdl|res://*/EntityFramework.NorthwindDataContext.ssdl|res://*/EntityFramework.NorthwindDataContext.msl;provider=System.Data.SqlClient;provider connection string="data source=SHRESTASOFT\SQLEXPRESS;initial catalog=NORTHWND;persist security info=True;user id=sa;password=tentod;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
Where could the database be created?
Update - One more help required: Please observe that ASHOKConnectionString is existing inside connectionstrings section of web.config. This is the one I am using currently for other pages. If I want to get my ASP.NET Identity related tables into this database, how can I do? Can anybody please suggest me!
You can find where the members are stored by looking the membership field on web.config. For example you have to see something like:
<roleManager ... >
<providers>
<clear/>
<add connectionStringName="ASHOKConnectionString" ... />
</providers>
</roleManager>
<membership >
<providers>
<clear/>
<add connectionStringName="ASHOKConnectionString" ... />
</providers>
</membership>
and inside that database that is used for members, there are 11 tables that starts with aspnet_ and there are your member.

ASP.NET MVC 4 application database connection issue after session timeout

I have an MVC 4 website using .NET framework 4.5 that works fine at first. It allows me to login and go about my business adding, deleteing and editing records. As such, it is obviously initially connecting to the database without a probelm. However, if I leave it inactive for a while and come back at a later time, and then click a link to a page that shows data from my database, I get the following error:
The SSE Provider did not find the database file specified in the connection string. At the configured trust level (below High trust level), the SSE provider cannot automatically create the database file.
The website works fine on my localhost, but not when I host it online. I use shared hosting for this. I've done extensive searching online and found lots of people getting the same error, but they don't seem to have a website that works initially and then suddenly stops working. The solutions I've found online say something along the lines of:
add these two lines to your web.config file
<remove name="LocalSqlServer"/>
<add name="LocalSqlServer" connectionString="Data Source=p3swhsql-v15.shr.phx3.secureserver.net; Initial Catalog=DatabaseName; User ID=****; Password='****';"/>
by default the .net site is trying to find your database in the local filesystem in this case would be the app_data subfolder under the wwwroot directory. simply removing the connectionstring and replacing it with the database connection solves the issue. My example utilizes an SQL db on godaddy's server. however i'm sure you can replace the connection string with the appropriate string for your connection. good luck and i hope this helps anyone that may be having this issue
What my program seems to be doing is using the online database when I first login, and then reverting to trying to use the database in the local filesystem once the session timesout. This is very frustrating. My web.config file looks as follows:
<connectionStrings>
<remove name="DefaultConnection"/>
<add name="DefaultConnection" connectionString="Data Source=winsqls01.cpt.wa.co.za;Initial Catalog=SportFantasySA;Persist Security Info=True;User ID=*****;Password=*****" providerName="System.Data.SqlClient"/>
</connectionStrings>
Please help. I'm desperate to get this working. I understand that it can't create the sql express database in the hosting space, that's why I'm using the connection string for the database on my hosting company's server.
If you have hosted it on Godaddy go for the connection string as
<providers>
<remove name="AspNetSqlMembershipProvider" />
<add name="AspNetSqlMembershipProvider" connectionStringName="LocalSqlServer"
..other attributes here... /></providers>
<connectionStrings>
<remove name="LocalSqlServer"/>
<add name="LocalSqlServer"
connectionString="Data Source=xxxx; Initial Catalog=xxx; User ID=xxx; Password=xxx;"
providerName="System.Data.SqlClient" />

Is it recommended to use seperate database for forms authentication for MVC4 project?

One database for the project and once for the authentication created by the MVC4 template.
Reply to Mystere Man:
I was following this MVC4 example:
It creates two connection strings in web.config file, one for forms authentication and the other one for product database.
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-ProductStore-20120829112625;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-ProductStore-20120829112625.mdf"
providerName="System.Data.SqlClient" />
<add name="OrdersContext" connectionString="Data Source=(localdb)\v11.0; Initial Catalog=OrdersContext-20120829131625; Integrated Security=True; MultipleActiveResultSets=True; AttachDbFilename=|DataDirectory|OrdersContext-20120829131625.mdf"
providerName="System.Data.SqlClient" />
</connectionStrings>
No. It's not recommended, but it's not "not reccomended" either. You can put your membership tables anywhere you want. What's recommended is to put them where you want them.
But frankly, I see no valid reason to use a separate database, other than personal preference. I personally think it's pointless to put them somewhere else. Now you have to backup two databases and keep the backups synchronized.

ASP.NET Sql Provider

I got a problem. When i'm creating the new project in ASP.NET using VS 2010, it's web.config with a default connection string about SQL Express created. But i haven't even got SQL Express installed. What should i do to change the default AspNetSqlProvider to work with my instance of full-weight SQL Server as a services database? And how can i change the template for the ASP.NET project to create a project with my connection?
You mean this one:
<add name="ApplicationServices"
connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true"
providerName="System.Data.SqlClient" />
To change this into one that'll work with SQL Server, it needs to look more like this:
<add name="ApplicationServices"
connectionString="data source=ServerName;Initial Catalog=DatabaseName"
providerName="System.Data.SqlClient" />
where DatabaseName is probably aspnetdb. It'll need some form of authentication, whether you use Windows authentication (in which case you can copy the Integrated Security element from the original connection string) or SQL Server authentication (where you'll have a username/password combination).
There's great info on building connection strings at connectionstrings.com.
To fix this for your future projects, you'll need to change the template for Web Projects. Locate the folder where your C# Web templates are kept (for me this is C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\ProjectTemplates\CSharp\Web\1033.
Take a copy of the WebApplicationProject40.zip file (you might also want to backup the original somewhere!).
Inside it you'll find the web.config file with the SQL Express connection string. Change it to a SQL Server string, and then re-assemble the zip file.
The last step is to rebuild the VS template cache - from a command-line (VS Command Prompt probably works best), run devenv /installvstemplates. See here for details.
I just had a similar problem. I had a web site created in VS 2008 and wanted to try web parts. Added some to a page, then started getting:
SQLExpress database file auto-creation error:
The connection string specifies a local Sql Server Express instance using a database >location within the applications App_Data directory.
I ran aspnet_regsql.exe (wizard, in .Net framework folder) to create the database and then I added a connection string to web.config:
<configuration>
<connectionStrings>
<add name="aspnet_membership" connectionString="Data Source=localhost; Initial Catalog=aspnetdb; Integrated Security=SSPI;"/>
</connectionStrings>
</configuration>
Then I added this to web.config:
<configuration>
<system.web>
<webParts>
<personalization defaultProvider="SqlPersonalizationProvider">
<providers>
<add name="SqlPersonalizationProvider"
type="System.Web.UI.WebControls.WebParts.SqlPersonalizationProvider"
connectionStringName="aspnet_membership"
applicationName="/" />
</providers>
<authorization>
<deny users="*" verbs="enterSharedScope" />
<allow users="*" verbs="modifyState" />
</authorization>
</personalization>
</webParts>
</system.web>
</configuration>

Is it possible to use a different database name with SqlMembershipProvider

Can I specify a different database than ASPNETDB using SqlMembershipProvider? I am developing a site on a shared host, and have to restrict my data schema to a single provided database.
I was roundly scolded last time I suggested rolling my own authentication code.
Alternatively, is there some other packaged authentication system I could drop in and configure to use an arbitrary database and tables from asp.net?
You can install the ASP.Net Membership Schema to any SQL database by using the aspnet_regsql command line tool.
You can also specify any connection string you'd like for your membership provider. Simply add something like this to your membership declaration in your web.config file:
<connectionStrings>
<add name="MyConnectionString" connectionString="Database=MyDatabase;Server=xxx;User=xxx;Pwd=xxx;" providerName="System.Data.SqlClient"/>
</connectionStrings>
<membership defaultProvider="MyProvider">
<providers>
<add connectionStringName="MyConnectionString" applicationName="/Test"
description="MyProvider" name="MyProvider" type="SqlMembershipProvider" />
</providers>
</membership>
The previous answer is largely correct, but I had a problem until I fully qualified the "Type" value to be "System.Web.Security.SqlMembershipProvider".
<membership defaultProvider="MyProvider">
<providers>
<add connectionStringName="MyProvider"
applicationName="/Test"
description="MyProvider"
name="MyProvider"
type="System.Web.Security.SqlMembershipProvider" />
</providers>
</membership>

Resources