简体   繁体   中英

Problem with ASP.NET MVC application deployment

I'm currently deploying my ASP.NET MVC5 project. I already deployed project files, but I got some problems with, I guess, the database. I did the following steps to deploy the database:

  1. Update-database -script in Visual Studio to get the SQL script of my local database (I developed it by code-first)

  2. Connect to the SQL Server database I created in my hosting panel.

  3. Run the script I generated in 1.

  4. Change the connection string in my web.config to this:

     <connectionStrings> <add name="DefaultConnection" connectionString="Data Source=xxxxxx.xxxwebix.xx,2401;Initial Catalog=xxxxx;User ID=xxxxx;Password=xxxxx" providerName=".NET Framework Data Provider for SQL Server" xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/> </connectionStrings>

So basically I filled it in with the same credentials I had used to connect to the DB to run the script.

Unfortunately, I'm unable to register or login. I get an error

An error occurred while processing your request.
500 (Internal Server Error)

in the console, which doesn't exactly say what's wrong. So basically, I know that the problem probably concerns the database, but I don't know what's wrong and how to get rid of it. This is my website (maybe it will help somehow): http://gymmanager.bartoszchodyla.pl.hostingasp.pl/

I'd be thankful for any help.

I found the problem - providerName.我发现了问题-providerName。 That's weird because I took it from the database properties after I connected to it in Visual Studio. I changed it to default "System.Data.SqlClient" and it worked. Does someone knows why?

There are a lot of things that could be going on here. The fact it is throwing a 500 error means either some code is causing a major error and/or you do not have friendly errors turned on.

There are some things you can do to figure out exactly where the issue is. In your console, make sure friendly errors are turned on, and you should get a bit more information. You can also add try... catches to where you think the issue is and avoid the exception and write a message instead (this is fairly crude, but quick and easy). Turning on tracing can also work, as long as you can actually spin up the application without the 500. You add trace statements before and after each routine and then go an examine the trace file. The same can be done, in more crude fashion, by writing to a file. The use of this method is you can turn trace on and off at will.

The fact you used code first is non-important if you are creating a SQL Script the correct way. When you run it, as long as it works (creates and possibly seeds?), you have the correct schema.

So, does the app throw the error up front or only when accessing data? If the latter, you have a good place to start seeking out errors.

BTW, you may be able to test locally against your providers database by changing your local connection strings. It will depend on having certain ports open, which you might even be able to do if they are not for security reasons. You can then debug the exception locally.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM