Hope you're doing well!
I will try to be brief,
I made a web service called "Contacts.asmx" that have this code:
[WebMethod]
public DataTable GetContacts()
{
string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand("SELECT * FROM Customers"))
{
using (SqlDataAdapter sda = new SqlDataAdapter())
{
cmd.Connection = con;
sda.SelectCommand = cmd;
using (DataTable dt = new DataTable())
{
dt.TableName = "Customers";
sda.Fill(dt);
return dt;
}
}
}
}
and and I have this code in my web.config
<add name="constr" connectionString="Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\user\Desktop\InternetApp\Folder\database.mdf;Integrated Security=True;Connect Timeout=30" providerName="System.Data.SqlClient"/>
Seems to be working fine and i'm getting the XML when i click invoke.
But after publishing website on IIS : http://localhost/Contacts, i'm having this problem:
What should i do?
Aucun commentaire:
Enregistrer un commentaire