Cannot connect to MS SQL from IIS [duplicate] - c#

This question already has answers here:
IIS applicationHost 'setEnvironment' attribute
(2 answers)
Closed 3 years ago.
I'm developing a .net core application. I have local SQL server. When I debug application from Visual Studio, it works great. But when I publish app to folder and want to run it from IIS, it cannot connect to database.
From database I found this error messages for failed logins:
Error: 17204, Severity: 16, State: 1.
FCB::Open failed: Could not open file C:\Users\p4too\AppData\Local\Temp\VS11CodeIndex\Microsoft.VsCodeIndex_86bc9b9e_7c02_4fe0_9598_c87ac2dd85db.mdf for file number 0. OS error: 3(The system cannot find the path specified.).
I was looking for that file, but I did not found even folder VS11CodeIndex.
I use
Entity framework core 2.2.4
SQL Server Management Studio 15.0.18118.0

This is what solved the problem for me... you need to open C:\Windows\System32\inetsrv\config\applicationHost.config in Notepad and add setProfileEnvironment="true" to your AppPool.
In IIS, configure the app pool to run under an account with permissions to the DB on the server (advanced options of the app pool)
In the advanced option of the app pool, set Load User Profile to true

Related

Unable to run the application from VS 2015 [duplicate]

This question already has an answer here:
"The underlying connection was closed: An unexpected error occurred on a send" after installing VS 2015 update 2
(1 answer)
Closed 4 years ago.
I am running my application using VS 2012 initially, That time it's working fine. After that we installed VS 2015 update 3. Now we are not able to run the application.
Getting Unable to start the debugging server on the web server. The Underlying connection was closed.An unexpected error occur on a send.
My application hosted in IIS, host entry fine with host file. I am able to run the application from IIS. And get the Verbosity -Diagnostic output. There is no conflicts between the packages. Firewall port is enabled as well as there is no Anti virus blocking.
Before installing VS 2015 it's working fine, Please let me know what is the issue here. Is there any .netframework conflicts, Please help to resolve the issue.
Try these:
Try changing the port being used to something other than 80 which may being used by another application.
Check to make sure the app pool has the right privileges.
Are VS2015 components installed on the remote to allow for VS2015 debugging? See Installing Remote Tools

System.InvalidOperationException: Failed to compile both on .NET 4.5 and on .NET 4.0. 4.5 Exception: System.IO.IOException: The file exists

We are running jobs on our application server and the jobs were running fine early in the morning and then in the afternoon they started failing with this error:
System.InvalidOperationException: Failed to compile both on .NET 4.5 and on .NET 4.0. 4.5 Exception: System.IO.IOException: The file exists
When Googling I find the error only once and it is dealing with a web server and not an application server. Suggestions for those were to remove files from the c:\windows\temp folder or from the %TEMP% folder. Then another was to run the Disk Cleanup Utility and then reboot the server. None of this has helped.
Does anyone have any idea as to why this is happening?
My environment:
Server is Windows 2012R2 Server
.NET Framework: 4.5
If the app is running under a specific user, make sure you also clear out the user temp folder. For example, make sure you clear out all items in C:\Users\<username>\AppData\Local\Temp where <username> is the user the application is running under.
Try clearing out the %TEMP% folder on the box the app is hosted, which for me was 'C:\windows\temp'.
You can do this from the command prompt:
c:\Windows\Temp>del c:\Windows\Temp\*.*
c:\Windows\Temp\*.*, Are you sure (Y/N)? y
Apparently, if there are too many files in the folder .NET is not able to serve web-pages through IIS.
See post about the issue here

Cant access database in Visual Studio after copying solution to another PC [duplicate]

This question already has answers here:
The database cannot be opened because it is version 851. This server supports version 782 and earlier. A downgrade path is not supported
(3 answers)
Closed 6 years ago.
I have created database using code-first approach with Entity Framework in Visual Studio 2015. I had to re-install windows on my PC, so after it, I downloaded my archived solution from dropbox and could not run it. I receive following error.
"The database 'aspnet-Sadly-20161110095352' cannot be opened because
it is version 852. This server supports version 782 and earlier. A
downgrade path is not supported. Cannot open database
"aspnet-Sadly-20161110095352" requested by the login. The login
failed. Login failed for user 'Myuser'."
How can I support downgrading path or resolve problem with login?
Thanks
You should disconnect and reconnect to that database (Server Name, User Name, Password).
In Visual Studio you can use SQL Server Object Explorer.
P.S. You should use Git repositories like GitHub or Bitbucket, not Dropbox ;)

Giving permission to your ASP.NET Application to a Directory in a File Server

I have a Web Server xxx.xxx.xxx.26 (let's call it .26), and it has an application using 'DefaultAppPool' as the Application Pool.
In that ASP.Net application there is supposed to be a capability of opening a file by using Process.Start() (I use C# btw)
string path = #"\\10.132.142.27\one_test\Advisory.msg";
Process.Start(path);
This works fine if I'm debugging or using localhost, but when it's publish in .26, the application says "Access denied" or "no network provider accepted the given network path". I googled every possible solutions but no luck so far. I already have given access to the User of the application in full control.
Specs:
Web Server: Server 2003 IIS is version 6,
VS2013 Framework 4
File Server: Server 2003/2012
What should I do to open the file? Please help! :'(

c# setup project with parameter [duplicate]

This question already has answers here:
Passing command line args to MSI from WiX bundle
(2 answers)
Closed 6 years ago.
I have developed an C# application that connects to a database on a different server. The connection string will be taken from the app.settings file.
Now as the application runs fine, my client (customer) would like to deploy the app to different client computers via a GPO. It is already working on my local computer and I can connect to the server (my server) because the app.settings will be installed correctly in the appropriate installation folder. But the value of the sql server in the app.settings is hardcoded in that file.
And due to the fact that I am not really aware of the SQL server name in the client environment I would like to give the client the possibility to setup and deploy the application with the server name as a parameter in the setup file.
Is that possible like run the setup script as "setup.exe -server 192.168.xxx.xxx"?
Many thanks!
You can add custom parameters to you installation project by adding custom screens with textboxes: .net Setup Project: How to pass multiple CustomActionData fields

Categories

Resources