DBResourceFactory issue on production (after publishing) - asp.net

I have a DBResourceFactory in my ASP.net project and the newly added resources (in the databsae) work fine on localhost but they dont work on production.if i add them to files(resx) they start working fine. but dont work through database. I have reset the IIS too.

This sounds like a db permission problem. You need to grant permission for the Application Pool identity that IIS is using for your website project to access the production database. You can do this in Sql Server Management Studio (if you are using Sql Server that is)

Related

ASP.NET Core - Application not connecting to database after publishing

I created a simple ASP.Net Core application with user authentication (so all the Entity Framework has been preloaded into the web app template). It is connecting to my database with the connectionString that is located in my appsettings.json file, with "data source = {computerName}\\{serverName}" setup.
The database instance and Visual Studio are located on the same machine. This works fine in returning data to the web api while within development and debugging mode. When I publish it and try to go to the site from a domain name it does allow me to view the webpages that are not needing database connection but the rest that need data from the database returns pages like this:
Error.
An error occurred while processing your request.
Development Mode
Swapping to Development environment will display more detailed information about the error that occurred.
Development environment should not be enabled in deployed
applications, as it can result in sensitive information from
exceptions being displayed to end users. For local debugging,
development environment can be enabled by setting the
ASPNETCORE_ENVIRONMENT environment variable to Development, and
restarting the application.
I have tried to change the Environment Variables for ASPNETCORE_ENVIRONMENT from Development to Production to no success.
I have tried adding appsettings.Production.json to publishOptions in my project.json file, even though there is no file appsettings.Production.json, and this did not help. dotnet publish
Adding the evironment variable in the web.config file did not work Deployment
I need help getting the published web api to connect to my SQL Server database from outside the development Visual Studio setup.
The last thing I can think of is that maybe I am incorrect in how I understand the connection string. If the web api uses the connection string to connect to the database from the server-side then it should work just fine like it does when in development calling to http://localhost:port# since it's all on the same machine. But, if the database string needs to be based on a client-side call then it would have to be with domain names and IP addresses.
Can someone tell me which one it is?
The only thing else that comes to mind is that there is something I am not doing, and need to do, inside of IIS Manager. I see connect string there as well but unsure what that is for our does since the connection string is inside the application. Also maybe I am suppose to give the app some kind of authorization to communicate with the database server even though they are on the same machine???
After much research, finally googling "how to deploy a web api in iis" I was able to learn from Host ASP.NET Web API in IIS using Visual Studio Publish that I needed to add the security entity BUILTIN\IIS_IUSRS. Then placing a mapping to my database tables and giving db_datareader (and possibly db_datawriter) for the database to the IUSER to allow access from my self hosted IIS web api. This from the above mentioned link with the part stating
Accessing Database under IIS APPPOOL\ASP.NET v4.0
As we are using ASP.NET v4.0 App Pool make sure IIS APPPOOL\ASP.NET v4.0 is added to your Database Server -> Security -> Logins.

MYOB ODBC ASP.NET application issues during insert command from IIS 10.0

I am trying to develop a ASP.NET Web API for MYOB that runs within IIS. That will allow me to insert/update/select different pieces of information from a MYOB company file.
At the moment within development everything works perfectly from within VS 2015 using IIS Express. I can successfully execute a insert command on the MYOB ODBC connection in multi-user access mode while the company file is opened by atleast two other users.
However when run from within IIS no errors are displayed. However the ODBC driver returns successfully on the insert query despite no insert being completed and no records of errors in any log files.
Finally, i have given the application pool connected to the IIS Application/Website the identity of the system administrator account. So i am assuming this is not the issue.
Could someone please help me on this! Have I maybe setup the permissions and security protocols in IIS incorrectly? As this application works fine within IIS Express but not in IIS?
Thanks in advance for any help!
You eventually couldn't see an error because you are using Web API. You are just a client. But maybe the API has an error that you've couldn't be seen. is your API has a LOGS? or it has a return value when it might encountered an error?
Try to Double Check it.
I agreed there's a big difference between iis express and IIS itself(Not in VS, means other machine or in server)
Check it too.
1.) framework you are working mostly.
2.) make sure that your Web API is running.
3.) IIS set up.

IIS7 application using wrong SQL Server 2008 Express database

I'm stumped. I have a client site on a virtual private server - Windows Web Server 2008 SP2, IIS7, SQL Server 2008 Express.
I'm trying to setup a second web application, to allow him to review updates prior to their going live. I've created the web application in IIS7, and I have added a second database to SQL Server. The second db is essentially a copy of the production db, with 'DEV' prefixed to the database name and a few new fields in a few tables.
My production site works fine. However, the test site comes back with an SqlException: "Invalid column name 'version'." This is one of the new fields - which leads me to believe that my dev site is referring to the production database, and not the dev database. Connection strings, however, do point to different databases (although the login is the same for both):
Production site: "Server=.\SQLExpress;Database=myDbName;User ID=myUserName;Password=myUserPassword;"
Dev site: "Server=.\SQLExpress;Database=DEVmyDbName;User ID=myUserName;Password=myUserPassword;"
Seems like this should be something obvious that I'm missing. A colleague suggested that I create another application pool for the second IIS application, but it does not seem to have helped.
UPDATE, following further testing:
I changed the dev site's connection string to
"Server=.\SQLExpress;Database=DEVmyDbName;User ID=devuser;Password=myNewDifferentPassword;"
and created a new SQL server login on the database, and only gave it access to the dev database. I also set the dev database as the account's default database. I removed access to the dev database from the production login. When I try to login to the site, I get the following error:
The server principal "devuser" is not able to access the database "myDbName" under the current security context.
As a result, there are two things I know for certain:
Since it's using the new username to login, I know the app is using the connection string I'm feeding it;
For some reason, once logged in, it appears to be ignoring the specified database and trying to use the production database instead.
I don't think it should make a difference, but I will mention I'm using NHibernate for database access.
Still stumped.
It turns out that NHibernate was significant. One of the NHibernate configuration options that was set was "default_schema" - when I removed it, the app started connecting to the correct database.
It appears that the default_schema property was overriding whatever database was specified in the connection string.

Permissions problem when accessing remote files from my Web Service

My web service needs to open some files located on a remote computer.
From Windows I can do the authentication so I can see those files using the File Explorer.
If I try to open the files from my Web Service while it's running using Visual Studio (ASP.NET Development Server) it also works.
However, if I do everything from IIS it doesn't.
In order to find out where is the problem what I did was to run a network sniffer and I found out that when using IIS, the system will try to use the account 'ASPNET' to login into those remote computers which will obviously fail.
However this doesn't happen if I run from the IDE (Using the ASP.NET Development Server)
I found out that if I use Impersonation for accessing this it will work, the problem is I need to have the same account names on the computer running IIS so I would rather not to do that.
Why is it working from the ASP.NET Development Server and not from IIS? Is there a way to give full access to the ASPNET account?
Thanks and hopefully somebody will be able to help with this. I don't know what else to try...
Any request on IIS is served by the ASPNET user. So the user ASPNET is working. I think you are using XP. On Win2K3 etc, the user is Network Service
But the Cassini (Visual Studio Dev server) runs under the current logged in user.
So the difference is. You need to use impersonation for your need.

How to use aspnetdb database with an asp.net website

I have created a website using asp.net 3.5.
And now I have added member support to it using Membership API and aspnetdb database.
And I have done all testing on my local machine.
Now, what issue needs to be considered with respect to aspnetdb while uploading this site to the server. ie; how this database will be available on the server side ?
Note : This is my first ever website.
I was just looking for an answer to this myself.
I've found the following that might help you:
http://www.studiocoast.com.au/knowledgebase/article-6-aspnet-using-sql-server-instead-of-aspnetdbmdf.aspx
"When developing applications in
ASP.NET 2.0, the default option for
roles and users is to use a local SQL
database in the App_Data directory.
This works fine locally, but will
bring up an error when uploaded to a
production server. To fix this the
ASP.NET membership information needs
to be stored in a dedicated SQL Server
database."
"ASP.NET includes a program called
Aspnet_regsql.exe which you can run
locally to configure your database.
More information on the program can be
found here:
http://msdn2.microsoft.com/en-us/library/ms229862.aspx"
Look in your C:\Windows\Microsoft.NET\Framework\v2.0.50727\ folder for the file InstallMembership.sql.
Thats the SQL script to create the database you need.

Resources