Nfurman 0 Junior Poster in Training

Hello guys. My future site physically locating in:
C:\inetpub\wwwroot directory, which is accessible as http://localhost.

IIS 7.0 knows this site as 127.0.0.2. This means, that I created new site in IIS and assigned physical location even the directory of my over-mentioned site.

Looks like everything works fine. In SQL Server with Management Studio I've created database. I use Ado.net to retrieve data and my connection string is:

SqlConnection conn = new SqlConnection("Data Source=NATHAN-PC;Initial Catalog=Onset_1;Integrated Security=True");
                SqlCommand CmdSql = new SqlCommand("INSERT INTO Mail (Date,Sender,Company,Email,Phone,AddressLine1,AddressLine2,Country,State,Message) Values(@now,@tbName,@tbCompany,@tbEmail,@tbPhone,@tbAddressLine1,@tbAddressLine2,@Country,@State,@tbMessage)", conn);

Works fine. User input injecting good, news appering on page....bla bla bla...
But once occationally I've opened the site typing in browser http://localhost/ons/
instead http://127.0.0.2. And voila, I see "Login failed for user 'NT AUTHORITY\IUSR'. Exception Details: System.Data.SqlClient.SqlException: Login failed for user 'NT AUTHORITY\IUSR'."

Now when I try to build FormView, GridView... I use their constructors and even getting access to DB, opening page I see error "Login failed for user 'NT AUTHORITY\IUSR'.

What's the difference? Well, I see, that hitting http://127.0.0.2 I'm talking with
IIS...Do I? But how this problem populating? How to make the system working in both directions?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.