Connect database from asp.net mvc hosted in a virtual machine - sql-server

I'm trying to host an app made in asp.net mvc 4. I've installed a virtual machine (Windows Server 2008) and then I've installed IIS server configured for that. I've got to deploy the app but logically I have a problem. My app uses SQL Server as database. So, when I try to log in to my app, the system is waiting until it shows me an error message. Logically I have not configured the database connection to handle data from the server. My question is, how do I have to configure from my IIS server in the virtual machine where I have hosted my app to connect to my SQL Server database?
Thanks!

Related

When I host 2 apps (Web API and Blazor server) on Windows Server 2019, the API localhost port refuses to connect to SQL Server database on IIS

When I publish both projects to a local Windows IIS, they both run smoothly, but when I publish to Windows Server 2019, I get an error
No connection could be made because the target machine actively refused it.(localhost: 7112)
Please help me - how should I configure my web.config after publishing to the live server?
I enabled websockets on both apps program.cs, I even opened the apps ports on the firewall, it's my first time deploying to a real live server, I'm not sure what I left behind

Django IIS and SQL with NT Authentication

Good morning. I have several Django apps running in my work environment. All are running through Gunicorn on Ubuntu. I have a new app that must run on Windows for ODBC reasons. This new app is running in development mode on a Windows 10 PC. I run the dev server while logged in as a service account, it uses a trusted connection (local credentials as I understand) to query a SQL server and works perfectly. I ported this app (virtualenv and all) to a Windows Server 2012 r2 instance and run the dev server successfully from there using my domain admin credentials (again trusted_connection=yes).
I set up IIS on this server to run the app permanently and it appears to run. However, I get a django error page that says the SQL login failed for 'DOMAINNAME\SERVERNAME'.
I have tried editing my Application Pool to use the credentials of the working service account (Advanced Settings > Process Model > Identity). With this configuration I no longer see a Django error page, just Service Unavailable HTTP Error 503. I have tried 'recycling' and restarting the IIS service after the change but that has not worked.
Unfortunately, I do not have admin access to the SQL server to create or edit accounts. Is it possible to configure IIS to connect to SQL, through the app, using the service account credentials that I know work. If I were to configure the Application Pool successfully in this way should I still have the trusted connection setting in my connection string? Thanks!

Deploy an Asp.net core web api to IIS but can't access by other computer using IP:{port}/api/{controller}

I wish to deploy an asp.net core web api to IIS on a windows server. On
that windows server the api can be accessed using http://localhost:5000/api/values.
But on another computer it can't be accessed using http://MyWebsiteIp:5000/api/values.
Chrome says
Can't access the website,ERR_CONNECTION_TIMED_OUT
And the firewall I have is closed so it doesn't work too. The api connects with a SQL Server Database and when I use VS debug on my commputer IIS Express the CRUD function can work using http://localhost:53450/api/{controller}.
But when I deploy to IIS on windows server it doesn't using http://localhost:5000/api/{controller}. I have copied the Database to Windows Server and placed it in the same path with my computer.
Could you help me ?

Using Power Desktop with an Azure VM and Enterprise Gateway

I am developing a report in PowerBI Desktop based on data hosted in an Azure SQL Server VM.
When publishing a report, I get the below error:
Publishing succeeded, but the published report cannot connect to the
data source because we were unable to find a gateway. Please install
and configure an enterprise gateway
I believe this is because the enterprise gateway is installed locally on my azure VM, however I'm accessing it from my desktop by going over the web and through the firewall. Therefore I believe the issue is that my pc acceses the machine at
mymachine.cloudapp.net
Whilst the enterprise gateway knows the machine as
netbios-name
Is there any way that I can upload a desktop report to powerBI web using this configuration? The other solution would be to get the machine and sql server to identify itself as "mymachine.cloudapp.net" so that I can use this as the name to connect to through the enterprise gateway, but I'm not sure how to do that (adding the alias to SQL Server isn't enough).
It's a bit hacky, but I've got a work around.
Open the server and edit your hosts file and add the following line:
127.0.0.1 mymachine.cloudapp.net
Make sure that mymachine.cloudapp.net has been configured in SQL Server as an alias.
In PowerBI, add a new enterprise gateway data source, this time, use mymachine.cloudapp.net to connect rather than netbios-name. You will need to use SQL Authentication to connect.
Obviously connecting PowerBI to an Azure VM in this way is not ideal, as it could potentially be unencrypted, but this works around the issue of different host names between PowerBI Desktop and Web.

Silverlight RIA query failing using authentication & impersonation

Database: Sql Server 2005
Webserver: IIS 5.0
IDE: Visual Studio 2010
I've created a Silverlight RIA application which will allow users of our intranet query one of our databases.
In the config I have set the authentication to windows and enabled impersonation.
In IIS i have disabled anonymous access and only enabled windows authentication.
This all works fine in my development environment and when running it from VS2010.
When i publish it to my local web server and connect to it from my local pc it works too.
However if i access the URL to the application on my local web server from another machine the application does not work. It gives the following error: "Load operation failed '[QueryName]'. Exception type 'System.ServiceModel.DomainServices.Client.DomainOperationException' was thrown.
The database sits on its own server. However i have the same database locally and if i change the connectionstring to local at the local version of that database it works fine.
IIS on my PC does not seem to forward requests to the SQL Server machine. As im running profiler to see what requests come in.
Any help on this would be greatly appreciated. Im sure im missing something.
Thanks
this was an issue was a classic double hop problem when using windows authentication. instead i used annoymous access on IIS and set the App Pool to an account that had access to the database on SQL Server

Resources