WCF service hosted on IIS7.5 when accessing database trhows error 400 bad request
I have a wcf service that has a method which returns List after collecting information from SQL Server 2008 based database. While working in developement mode there is absolutly no probl开发者_Python百科em, but when I run the service on IIS and try to access the method that is getting information from the database, the browser returns: "bad request 400". When I call a method that is not working with databases it succeeds.
I am really desperate - I serached and searched, tried different things but nothing worked. Thank you,
It's almost assuredly a permissions problem. Without knowing your specific setup, here are some things to look for:
- If using Windows Authentication to your SQL Server database, make sure that the identity used by your service's app pool has the correct permissions to the SQL Server database/tables/etc.
- If using SQL Authentication to your SQL Server database, make sure that the username/password is correct in the connection string and that permissions are setup correctly in the database.
Unless you are using impersonation or have specified a specific user at your site level in IIS, it's likely one of the above.
My guess is that you are using Windows Authentication to connect to your SQL Server database and you have not specified an App Pool Identity. My advice is to use a specific account for your app pool (domain\username) and then give that account the proper database permissions.
You also should configure tracing to capture the real exception.
精彩评论