I have an Runtime error when I'm trying to perform login action or create user action on published website.
I have an ASPNETDB.MDF in appData folder, that created from ASP.NET Configuration.
I created new database in hosting, exported from ASPNETDB.MDF to a new database. I changed connection string.
Localy it work perfect, even with new connection string, but after i publish it i have an Runtime error.
I'm using asp login control and CreateUserWizard.
BTW, i've created some GridView and SqlDataSource to show all users, and it works.. But login and createWizard are not.
web.config
<configuration>
<connectionStrings>
<add name="ConnectionString" connectionString="Server=mssql3322.dotnet-host.com;Database=aspnetdb3;Uid=SomeUserNAme;Password=SomePassword;" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<roleManager enabled="true" />
<authentication mode="Forms" />
<compilation debug="false" targetFramework="4.0" />
</system.web>
</configuration>
BTW, i tryed to add membership provider to web.config and it didn't work even localy ))
UPD:
The error
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)
Well for starters you could add the following to your web.config:
<configuration>
<system.web>
<customErrors mode="off"></customErrors>
</system.web>
</configuration>
This should allow you to get a more detailed error message about what is wrong. See if that get's you started down the right path. It should at least provide more information about what might be wrong.
Update - try this in your web.config:
<connectionStrings>
<remove name="LocalSqlServer" />
<add name="LocalSqlServer" connectionString="Server=mssql3322.dotnet-host.com;Database=aspnetdb3;Uid=SomeUserNAme;Password=SomePassword;" providerName="System.Data.SqlClient"/>
<add name="ConnectionString" connectionString="Server=mssql3322.dotnet-host.com;Database=aspnetdb3;Uid=SomeUserNAme;Password=SomePassword;" providerName="System.Data.SqlClient"/>
</connectionStrings>
Update - That worked! Here is a short explanation why:
By default the ASP membership classes use the connection string LocalSqlServer. The reason the code worked on your local machine is because the connection LocalSqlServer is defined in a machine level config file to point to the local sql database. When you published it the SqlDataSource/GridView worked because it was pulling the connection named ConnectionString that pointed to the correct server. However ASP membership was still trying to connect to the LocalSqlServer connection. The above config just ignores the machine level LocalSqlServer connection and defines it's own (and it leaves the ConnectionString one in place so that the GridView continues to function).
Related
I am getting a problem when I try to connect from my website to my database on my webserver (smarterasp.net). Everything works fine on the local host, then I uploaded the site to smarterasp.net and created the database there, now the site can't connect to the database, here is what I have in my web.config:
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="UsersConnectionString1" connectionString="Data Source=MYSQL5012.Smarterasp.net;Initial Catalog=db_9df63f_active;Uid=9df63f_active;Pwd=MYPASSWORD; "
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<compilation targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
</appSettings>
</configuration>
Where password obviously includes my real password.
Here is what smarterasp.net provided as the connection string:
ASP.net "Server=MYSQL5012.Smarterasp.net;Database=db_9df63f_active;Uid=9df63f_active;Pwd=YOUR_DB_PASSWORD;"
Classic ASP "Driver={MySQL ODBC 5.1 Driver};Server=MYSQL5012.Smarterasp.net;Database=db_9df63f_active;Uid=9df63f_active;Password=YOUR_DB_PASSWORD;"
I also tried putting the connection string in the web.config file as connectionString= "Server=MYSQL5012.Smarterasp.net; Database=db_9df63f_active; Uid=9df63f_active; Pwd=MYPASSWORD;"
but this didn't work either.
Appreciate any help. Thanks!
It looks like smarterasp.net does not allow remote database connections if you dont have a premium account.
to solve that problem , after you publish your website, navigate to the file manager , on the root of your files on your website , there is a webconfig , edit it and modify the connection string there , replace it with the connection string given to you by the website database section.
on the websites webconfig file
After searching my question's answer from stack overflow and other forums i am going to ask it myself, may be some one can guide me and make my way easy with asp.net programming.
I have a issue with saving values from my live website to database but all time i got error.
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.
Details: To enable the details of this specific error message to be viewable on remote machines, please create a tag within a "web.config" configuration file located in the root directory of the current web application. This tag should then have its "mode" attribute set to "Off".
i have tried to view it by putting mode=off in my web.config but i am unable to view details of my error.
here is my web.config
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<customErrors mode="Off"/>
<compilation debug="true"/>
<authentication mode="None"/>
</system.web>
<location allowOverride="true">
<appSettings>
<add key="#" value="Password=#;Persist Security Info=True;User ID=#;Initial Catalog=#;Data Source=#"/>
</appSettings>
</location>
</configuration>
I have tested my database and my connection string on my live database using local solution of my project but when ever i tried to test it using my live server which is arvixe i am unable.
My fellow suggest me to use
<connectionStrings>
<add name="#" connectionString="Data Source=#;Initial Catalog=#;Integrated Security=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
but it is not working with live server.
I am using app settings for connection string and i am confident with it because it is working fine with my local and live database.
I request to developers to test my online quran reading page and try to figure it out.
If you're using Sql Express, try this connection string
Data Source=.\SQLEXPRESS;DataBase=DBName;User ID=abcd;Password=xxxx;
As far as I know Integrated Security=True works with windows authentication. If you want to use this option then change the <authentication mode="None"/> to <authentication mode="Windows"/>.
If you are using Sql Server, may be try the following connection string
Standard Connection string
Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;
Trusted Connection
Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;
I am try to uploading website.I don't know how configure database(web.config file) on uploading time.I am using Somee.com , anyone familiar with somee.com Or know how to configure database the please help me.
webconfig file code
<configuration>
<connectionStrings>
<add name="abc" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Jai-Ganesh\Documents\Visual Studio 2010\WebSites\testinmg\App_Data\Database.mdf;Integrated Security=True;User Instance=True"/>
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
<customErrors mode="RemoteOnly" ></customErrors>
</system.web>
</configuration>
Note: I don't know what is path of the dataSource in server.
Link of the page:
[http://www.imureditor.somee.com/add_value.aspx][1]
first you need to contact your hosting provider for connection string. They will give you the ip address (you can also the host name) which you can then configure it.
See the exmaple below;
<add name="connectStringName" connectionString="Data Source=somee.com;User ID=yourusernameforDB;password=yourpasswordforDB;Initial Catalog=yourDBName;" />
OR take a real example below;
<add name="KenSchoolConnectionString" connectionString="Password=1234;Data Source=192.168.1.1;Integrated Security=False;Initial Catalog=KenMISSchoolDB;User ID=sa" />
OR
Go to connectionstrings.com
Your connection string references your local SQL Server instance and tries to attach a local file; this connection string will need to be changed to reflect the setup on the server, so you'll need to specify the Data Source, Catalog, User ID and Password - Integrated Security won't work, and attaching *.mdf files from App_Data probably won't either.
Your service provider is responsible for giving you the credentials needed for this, we can't guess them.
I have created a database on my host using SQL server management studio and have uploaded my website, App_Code and App_Data folders. My connection string is as follows:
<connectionStrings>
<add name="abc"
connectionString="Data Source=serverNane;
Initial Catalog=dbname;
Integrated Security=false;
User ID=user;
Password=pwd"
providerName="System.Data.SqlClient" />
</connectionStrings>
On using my login page, i got an error as i had not added customErrors to my web.config file. After adding customErrors and a default errors page, i can not understand what error has occurred as the stack trace is not visible. Is there something wrong with my connection string?
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>