Problem with ASP.NET MVC application deployment - asp.net

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:
Update-database -script in Visual Studio to get the SQL script of my local database (I developed it by code-first)
Connect to the SQL Server database I created in my hosting panel.
Run the script I generated in 1.
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.
EDIT
I found the problem - 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.

Related

vb.net Sys.WebForms.PageRequestManagerServerErrorException error

I'm coming across this error when I run my web app. The error is given only when the code is run on my web server. I can run the exact same code on my local machine and it works just fine. The the only way that I see the error when running the app on my webserver is if I press f12 when I try to run a given page. The page is trying to SFTP a file to another server, but like I said, I can run the exact same code on my local machine with no errors so I know that the code will work. There are no message or error boxes that popup. I've gone over the code over and over as well as looking at the difference of the configuration and programs that are installed on my local machine as opposed to what is on my web server. There is nothing that I see that is different. Here is the whole error message I see:
Sys.WebForms.PageRequestManagerServerErrorException: The source was
not found, but some or all event logs could not be searched. To
create the source, you need permission to read all event logs to make
sure that the new source name is unique. Inaccessible logs: Security.
I've found quite a few questions about this error, most of them talk about giving access to all users in this registry key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Security
or adding a user called Network Service to the above key and giving it full access or granting read permissions for the Network Service user to the whole EventLog branch. Another path I've explored is to change the identity of the app pool in IIS and then change it back. I've tried just about everything listed on SO and other places. Like I said, most of them involve writing new keys and changing permissions on keys in the registry. Another one I've tried is creating a registry key named HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\eventlog\Application\#MY APP# and then creating a string value inside it called EventMessageFile with the value of C:\Windows\Microsoft.NET\Framework\v4.0.30319\EventLogMessages.dll in it. Another suggestion is to open the the app as an Administrator. That didn't work either. I could go on and on and on but for the sake of not turning this into a novel I won't, but I hope I've shown enough examples to let everyone know that I've done due diligence in trying other solutions first before asking my question. Will someone please help me out with this very frustrating error?

Traceparser and the SQL tab

I have used Dynamics AX Traceparser on a number of occasions and usually without issues. This time however I can't seem to manage to generate and AX ETW trace that will show SQL in my TraceParser.
I can confirm it's not because I didn't load a server session, so it's not this question.
Things I have tried:
I looked in the traceparser database, there is not a single query in there
I did the whole run as administrator thing
I verified registry settings
I started tracing from both server config and client config.
I tried converting the .trc file to an xml file using tracerpt but the resulting xml doesn't make much sense.
I tried deactivating the DATAAREAIDLITERALS in SQLSYSTEMSETTINGS
Things that are different/uncommon about this environment
I can't install the client and traceparser on the AOS itself
AX Build 5.0.1600.2967 has been installed (incorporating the DATAAREAIDLITERALS change) because this customer has a lot of parameter sniffing issues.
Does anybody have an idea what could be the issue?
Has anyone tested traces on an AX with that specific patch (as I can imagine the query generation change could affect the trace .mof configuration)
If anyone can suggest me of a way to verify if the trace actually contains SQL information that would be of help too, because now I have no clue if the tracing fails or the importing.

Database permission denial when using IIS

Not entirely sure how to phrase this, so I'll just give as much information as possible.
I've got an asp.net application that uses SELECT on a database table. The connection string is something to the tune of:
"Data Source=Data\Source;Initial Catalog=DataStore; Integrated Security=True"
This works when I use the application locally. Query is executed, information is retrieved, everything's gravy.
The problem is when I try to publish my website using iis. After I publish it, I get the following error when I try to execute the query:
The SELECT permission was denied on the object 'object', database 'DataStore', schema 'dbo'.
I'm kind of stumped here and I'm not that familiar with IIS or security. Any help is appreciated, and I'll try to answer any questions you might have as quickly as possible.
You have the classic double-hop problem, you can read about it many places, like here and read how to do it right here, or go the easy route and put sql authentication user name and passwords in clear text in your config file.

Crystal Reports Viewer: Failed to Open the Connection error

Currently I'm working on a piece of code that involves using the Crystal Reports Viewer to export .RPT files to PDF. My problem is that the code works on literally everything except the website I'm planning to eventually put it on.
When placed on the website it throws back the error "Failed to open the connection." which I believe is connected to the SQL Server connection that's formed in order to read data for the report itself.
The code itself is solid and works when used in a separate console application I built to test it whether said code is run on my local machine or on the server itself. It even runs when I test the website in Visual Studio's virtual host.
I've narrowed it down to being some sort of permissions issue, but I am not knowledgeable enough in the various permissions settings to figure out which ones specifically apply to this situation. It's worth mentioning that other pages on the website are directly connecting to the same database, but they are doing so directly through Linq instead of going through the Crystal Report Viewer.
So does anybody know which settings I need to modify in order to fix the connection error.
An added note: One of the other suggestions is to make sure there's an ODBC DNS in place that matches the one being used by the code. I have created such a DNS already.
Application Pool dictates how your application runs in many ways. You can probably configure the web.config to run under the credentials, or access level of your choice.
Solution for people who didn't read the comments:
Change the identity under the advanced setting's of your application pool to the desired level of access.
Glad I could help.- J

Creating Membership DB (ASPNETDB) on remote server?

I'm building a web application which soon I'll be promoting to production. This application has a login screen, as you know I used the integrated DB for developing. Now I want to move this database to a full SQL Server 2005. I'm using the aspnet_regsql.exe to create my membership tables and stored procedures in the SQL Server 2005 but I'm getting an error:
An error occurred during the execution of the SQL file 'InstallMembership.sql'. The SQL error number is 207 and the SqlException message is: Invalid column name 'FailedPasswordAnswerAttemptWindowStart'.
I google this for half of the day already and I can't seem to fine what's wrong, does anybody have ANY ideas on what am I doing wrong here? Any help will be really appreciate it.
The easiest way to deploy a brand new database to a remote server is to just publish the database from within Visual Studio. Once you do that you have the scheme and data all in one script. You then access your server either via a local SQL manager connection or a remote manager and run the script on your remote database.
The site 4GuysFromRolla has a nice little walk through with graphics which describe how to accomplish the publishing of your local database to your hosted one.
Good luck, and hope this helps you out some.
Go through the *.sql script file and see where that column reference is. Then you'll be able to see what exactly the script is doing to cause this error. My guess would be that it is getting caught up on referential integrity. If it is trying to create a foreign key constraint that that table/column does not exist then you'll see that error.
But back to the original question at hand. You don't need to recreate your whole database. That script file is to lay down the Membership for an empty database. If you have a working dev database you can just back it up and restore it to a production instance. No need to rebuild the membership database objects.

Resources