Click here to Skip to main content
15,868,125 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I host a website on iis 7 on my local machine..

That website running proper when we run with code on same machine using visual studio 2010.

but on same machine when we put publish file using iis7 hosting then

con.Open() (sql connection faild) not working on iis on the same machine


here i am asp.net frramework 4.0 and sql server 2008 r2

Please any one help for the same..
Posted
Comments
norbitrial 31-Oct-13 14:04pm    
What is the exception details of conn.Open()?
mgoad99 31-Oct-13 16:10pm    
I cant say for sure without more info, like an error message, some code. But, my instinct says that the problem is most likely a security issue.

When you run your application in visual studio, it runs under the account you are logged in as. That is most likely the account that is used to connect to the database.

When you run under iis, the account that is used to connect to the database is different than on your machine with visual studio most likely would not have access.
Ganesh_verma 1-Nov-13 0:46am    
the exception is

Login failed for user 'IIS APPPOOL\ASP.NET v4.0'
mgoad99 1-Nov-13 10:00am    
I answered a similar question a while back. Check that out, hopefully it will help.

http://www.codeproject.com/Answers/656025/IIS-Error-on-localhost-for-ASP-NET-Web-App#answer1
Foothill 31-Oct-13 17:20pm    
I've had this problem when I was learning how to interface web pages and SQL databases as well. We had to set up a role in the database for read and execute. Then we had to give the AppPool that ran the page permissions to the role. It gets a little more complicated if the database is using schema's other than dbo.

Try this Link
 
Share this answer
 
Login failed for user IIS APPPOOL\ASP.NET v4.0 means you are likely using Integrated Security in your connection string. This means that since your app is running in IIS as ASP.Net v.40 user it does not have a login to SQL. You either need to create a login to sql for it or the best option is to create a sql account and use that in your connection string instead of integrated security.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900