Ahmed
Ahmed

Reputation: 525

I get Internal Server Error whenever editing connection string in ASP.NET MVC's web.config file

I made ASP.NET MVC web application and uploaded it to GoDaddy. Whenever I change the connection string in the web.config to data source=[Server IP];initial catalog=[Database Name];user id=[Username];password=[Password];, I get this error

500 - Internal server error.

If I made it like this data source=[Server IP];initial catalog=[Database Name];integrated security=true; , I get the following error -which is expected since the database is on a different server than the web application-

Login failed. The login is from an untrusted domain and cannot be used with Windows authentication.

So, it seems that the problem is somehow related to the integrated security part. Also it's working without issues on my local machine, and I cann connect to the database server using the same credentials I use in the web.config file.

How can I solve this issue?

Upvotes: 0

Views: 1256

Answers (1)

Ahmed
Ahmed

Reputation: 525

I figured it out at last.

Firstly I added this line to web.config file in an attempt to see a detailed error message

<system.webServer>
   <httpErrors errorMode="Detailed"/>
   ...
</system.webServer>

But I got the same error again.

500 - Internal server error.

In this stage, I was quite sure that the error is within the web.config, and not something else.

After focusing on revising the file and consulting aquentenance of mine, it turned out that the error was in the connection string at the database password!!!!

What happened is that I generated a random password for the database using GoDaddy, and it was something like this q59M&aw8. As you know & is an illegal character in XML, so it corrupted the whole file.

The solution is to either escape it like so & => &amp;, or avoid using illegal characters as passwords.

Upvotes: 1

Related Questions