Can not open database error from IIS - c#

Hi I just tryed to run my application fopr the first time on IIS.
Everything worked find while developing on visual studio but when I added the app to IIS I got this error:
Cannot open user default database. Login failed.
Login failed for user 'IIS APPPOOL\forum'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Cannot open user default database.
What should I do the site works when I run it from visual studio?
EDIT
I did a litle more digging and I managed to find out that I needed to setmy application pool identity to NetworkService I did that but now I got another error :
Unable to open the physical file "D:\Projects IDE\Visual Studio\MyWork\Websites\Forum\App_Data\ASPNETDB.MDF". Operating system error 5: "5(Access is denied.)".
An attempt to attach an auto-named database for file D:\Projects IDE\Visual Studio\MyWork\Websites\Forum\App_Data\ASPNETDB.MDF failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

Please check two places
1 Access to folder for the NetworkService identity(default for IIS app pool) or for this one(IIS APPPOOL\forum)
2 Connection string credetial. And if there "Integrated security". Provide Specific user and passwrod there.

I received this non explicit error because I had the Application Pool set to .NET 2.0 as opposed to .NET 4.0 on a service that was responsible for authentication. Typically when the framework is incorrect a different type of error about a non-recognized framework .dll is displayed, but not in this case. If this happens, check the following:
The value after IIS APPPOOL is the name of the application pool this current process is run under. In your case there was an AppPool named forum.
Check that the app pool is using the corrected pipeline and .NET Framework required for the application being run.

Related

Error in the path of an IIS server in Asp.net

I have a small web application in Asp.net.
Everything works fine on my computer. When I publish on my IIS server I get this error:
Exception details: System.Runtime.InteropServices.ExternalException: Generic error in GDI +.
The error is generated by this line:
bitmap.Save(cPathImage + "Immagini/tempimage.bmp");
cPathImage is HttpContext.Current.Server.MapPath("/");
This is the interesting part of the error stack on the IIS server:
Sicaweb._Default.CreateImage() in D:\DOTNET2019\Sicaweb\Default.aspx.cs:184
The folder D:\DOTNET2019\Sicaweb is the one present on my pc, it doesn't exist on the server and I don't understand where it comes from.
If I check the cPathImage variable on the server it is C:\inetpub\sica\
I don't really understand what happens.
I solved the problem myself, it was caused by Visual Studio which restores the permissions of the folders with each publication.
Thanks to those who gave -1 for no reason.

Google Speech - After Hosting getting Unauthenticated Error

I have created a web api method to Speech to text using Google Speech library. It is working fine when I execute using the visual studio. After hosting the application on IIS, I am getting below error when the api method is called
Method:Status(StatusCode=Unauthenticated, Detail="Getting metadata from plugin failed with error: Exception occurred in metadata credentials plugin.")
Error at line with code:
var speechResponse = speech.Recognize(SpeechConfig,
RecognitionAudio.FromFile(fileToProcess));*
And on another system, I have configured the GOOGLE_APPLICATION_CREDENTIALS env avariable with service account json, but I am getting below error
The Application Default Credentials are not available. They are available if running in Google Compute Engine. Otherwise, the environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined pointing to a file defining the credentials.
Do you also have compact framework sdk installed for visual studio? if try adding
< NoStdLib > False< / NoStdLib >
in your *.csproj file. This would force VS to use the std mscorlib.dll instead of compact one.
Check if the date and time on your system are correct (should be with 60 seconds of actual time)

Application cannot access USB Token in remote

I'm trying to create a C# console application using SignFile lib to access Token USB (contain Digital Signature) to sign a folder of PDF files.
The problem is after build Release to run on Windows Server 2012, this application run successful without any error (with Administrator account). But when I try to run with remote in my laptop (using Administrator account too), this application run error with this code:
Unhandled Exception : System.Security.Cryptography.CryptographicException: Bypassing PIN exception: An internal error occured
Anyone got any ideas about this situation?

System.ComponentModel.Win32Exception: Access is denied..... Error

I want to open one document file on our website. For that I write following code.
try
{
Process proc = new Process();
proc.StartInfo = new ProcessStartInfo(Server.MapPath("~/Quatation/PREMIUMQUOTATION1.doc"));
proc.Start();
}
catch (WebException we)
{
}
It runs locally very fine but web on web server it gives me an error like
System.ComponentModel.Win32Exception: Access is denied?
Please suggest, what should I do?
I had this problem when my .NET Target Framework was set to 4.5.2. I fixed it by changing the target framework version to 4.5. To do this using Visual Studio 2015, open Solution Explorer, right click on your solution and click Properties. The "Target Framework" should be set to ".NET Framework 4.5". Additionally, if you previously built with a target framework other than 4.5, you may have a <compiler> section in your web.config, and this may throw an error when you build. Just remove this section to fix the issue. Removing it should not cause any problems.
I wrote a short article about this here that has a couple other things to try that didn't work for me but might work for you.
Also check out This Stack Overflow answer which also helped numerous people with this error!
may be your SQL server is off
check it in services and start it
It sounds like you haven't changed the service logon user. You can do it from service control manager by right clicking the service and go to the Logon tab.
Then add user as Service Logon User
Or you can do it from the command line:
sc config ServiceName obj= Domain\user password= pass
Note the space between obj= and Domain\user it is not a typo. It is required. The same for password=.
My problem solve with this
In IIS Manage->Pool Application->Advance Setting->Identity
change to Custom Account and set Administrator User
Goto windows explorer and right click on the folder "~/Quatation/". Select properties and pick the Security tab to give permissions. In the case where your application pool under which the web application runs is using a domain account, you will need to give that specific domain account permission.
I faced the same issue while running my website from local IIS, after spending some time reading the project properties, found that, certain changes to the project properties were not saved...
Once it was saved, the error went away...
I got this error while I was working in visual studio 2017, using dotNet framework 4.5, in MVC project...
If you are getting this exception maybe you don't have the administration rights to your system so check with your admin and ask for the rights. If you do have administrator rights please open your IDE(e.g Visual Studio as an Administrator).You might also get this exception if you are trying to access the processes of 32 bit configuration system but your system has 64 bit configuration.
I am using .Net 4.5.2 and IIS 8.5.9
In IIS Manage->Pool Application->Advance Setting->Identity change
ApplicationPoolIdentity to Custom Account and set Administrator User

how to modify app.manifest in order to publish an app what needs database permissions?

I want to publish an xbap app but I can't get it due to a problem with ClickOnce.
My app needs to use an oracle database. If I publish it with enabled ClickOnce and 'this is a partial trust application' the publishing is OK, but the access to database doesn't work.
If I choose 'this is a full trust application' I can't publish.
I have tried to disable ClickOnce but the wizard enables it again.
Also, I have tried to custom and edit permissions XML and where it reads:
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
I have written:
But an exception is ocurred:
ClickOnce is not support the request execution level 'requireAdministrator'
Any help is useful for me.
The errors are:
An exception occurred when determining confidence. We detected the
following error messages: User has declined to grant the required
permissions for the application.
An exception occurred while downloading the application. We detected
the following error messages: AssertApplicationRequirements method
failed. The application can not be confirmed.
But I don't know what AssertApplicationRequirements is.
According to this post on Connect you have to use caspol.exe to fix this:
From the computer that you are trying to run the XBAP application on,
can you run the following command (you can run it from the Run Dialog,
or a command prompt):
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\caspol -m -ag 1 -url
"http://localhost/xbaptest/clickonce*" FullTrust -exclusive on

Categories