i'm new to asp.net & and IIS, i'm developing a website using asp.net for learning. First i create a new blank web site using vwd and the physical directory is C:\inetpub\web1, but later i moved web1 to C:\inetpub\wwwroot and opened IIS and turn the directory to the application and try to run it using browser the error message occur,
Server Error in '/web1' Application.
Cannot open database "testdb" requested by the login. The login failed.
Login failed for user 'IIS APPPOOL\DefaultAppPool'.
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 database "testdb" requested by the login. The login failed.
Login failed for user 'IIS APPPOOL\DefaultAppPool'.
Source Error:
Line 34:
Line 35: SqlConnection dbCon = new SqlConnection(ConfigurationManager.ConnectionStrings["testConnectionString"].ConnectionString);
Line 36: dbCon.Open();
Line 37:
Source File: c:\inetpub\wwwroot\web1\App_Code\tree.cs Line: 36
Stack Trace:
[SqlException (0x80131904): Cannot open database "test" requested by the login. The login failed.
Login failed for user 'IIS APPPOOL\DefaultAppPool'.]
System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +1270
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +108
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +126
System.Data.SqlClient.SqlConnection.Open() +125
Node.buildTree(String contentType, String mode) in c:\inetpub\wwwroot\web1\App_Code\tree.cs:36
header.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\web1\header.aspx.cs:14
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +91
System.Web.UI.Control.LoadRecursive() +74
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207
Anyone know what is the problem?
thanks
The error looks pretty clear to me:
Login failed for user 'IIS APPPOOL\DefaultAppPool', at DbConnectionPool.GetConnection.
I suppose the site was previously in an application pool that was run by NT AUTHORITY\NETWORK SERVICE, and that user was given permissions on the database you want to use, using Integrated Security.
If this is the case, simply change the user your Application Pool runs under.
Related
i am working on a web page to upload MP4 video and getting a thumbnail from the video
i am using NReco FFMpeg Converter to achieve this . it is working fine locally but upload it on a shared hosting it crashes at ffMpeg.GetVideoThumbnail
string VideoUrl = dataMediaUrl.ImageUrl;
string extension = VideoUrl.Split('.')[VideoUrl.Split('.').Length - 1];
var ffMpeg = new NReco.VideoConverter.FFMpegConverter();
string thumbnailJPEGpath = Server.MapPath(VideoUrl.Replace("~/upload/MediaGallery/", "~/upload/MediaGallery/Thumb_").Replace("." + extension, ".jpg"));
ffMpeg.GetVideoThumbnail(Server.MapPath(VideoUrl), thumbnailJPEGpath);
dataThumbUrl.ImageUrl = VideoUrl.Replace("~/upload/MediaGallery/", "~/upload/MediaGallery/Thumb_").Replace("." + extension, ".jpg");
This is the error I am getting:
Server Error in '/' Application.
This program is blocked by group policy. For more information, contact your system administrator
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.ComponentModel.Win32Exception: This program is blocked by group policy. For more information, contact your system administrator
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[Win32Exception (0x80004005): This program is blocked by group policy. For more information, contact your system administrator]
System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo) +1889
System.Diagnostics.Process.Start() +119
System.Diagnostics.Process.Start(ProcessStartInfo startInfo) +49
NReco.VideoConverter.FFMpegConverter.ConvertMedia(Media input, Media output, ConvertSettings settings) +1163
NReco.VideoConverter.FFMpegConverter.GetVideoThumbnail(String inputFile, String outputFile, Nullable`1 frameTime) +155
Admin_MediaGalleryVideoUpload.InsertButton_Click(Object sender, EventArgs e) +591
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9782698
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +204
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +12
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +15
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1639
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.3394.0
Your problem is that part of the code (probably inside of one of the methods you call):
System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
If it execute a process on a remote machine the user that execute it need to have the permissions to execute programs on it (not granted by default).
To help you more we need to know the source code of method where StartWithCreateProcess is called ( NReco.VideoConverter.FFMpegConverter.GetVideoThumbnail(...)).
EDIT:
Googling a bit seems that NReco is an external library, i suggest to open a ticket to their support.
I’m trying to run a sample from an Azure SDK winch communicates with the Azure MFA service. The sample compiles and runs in visual studio but once I deploy it to IIS I get the error below:
Access is denied.
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.Security.Cryptography.CryptographicException: Access is denied.
I suspect it’s related to a certificate that is needed to authenticate to the Azure service but not sure how to troubleshoot as I’m not a developer by trade. The certificate is in the same location as the ASP app and it’s referenced correctly in the code. Again, the code works through Visual Studio.
Stack Trace:
[CryptographicException: Access is denied.
]
System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 hr) +41
System.Security.Cryptography.X509Certificates.X509Utils._QueryCertFileType(String fileName) +0
System.Security.Cryptography.X509Certificates.X509Certificate.LoadCertificateFromFile(String fileName, Object password, X509KeyStorageFlags keyStorageFlags) +125
System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(String fileName, String password, X509KeyStorageFlags keyStorageFlags) +141
pf_auth.send_message(String target, String message, String cert_file_path, String& body) +221
pf_auth.pf_authenticate_internal(PfAuthParams pfAuthParams, Boolean asynchronous, String& otp, Int32& call_status, Int32& error_id) +744
MFADemo.example.btnTest_Click(Object sender, EventArgs e) +1602
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +11754953
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +150
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3619
I think you are better off uploading the cert to your application in Azure Management portal in the Configure tab:
And then in the code your Cert store location should be "CurrentUser" instead of "LocalMachine" for it to work in Azure...
We had multiple issues with reading certificates from file system in Azure and ended up uploading it to he Azure website and reading it from the store...
I am working on a Website that was donated to our institution, right now I'm trying to decide exactly how to set up two connection strings (CS) in the Web.config file (some of the details in these connection strings were redacted by the donator).
The CS I have a question about is referenced in sessionState:
<sessionState allowCustomSqlDatabase="true" mode="SQLServer" sqlConnectionString="DevelopmentSessionState" cookieless="false" timeout="20"/>
I'm trying to determine what type of Account I should be using for the UserID in the SessionState CS. In order to get the Website functional I used the sa account, but I know this isn't a good idea - I'm looking for an account to replace sa. I have no idea if this is a user I should define in SQL Server, or if I should use a pre-existing account, or what type of access this user should have.
I am also fuzzy on the idea of why a separate connection string is needed for Session State. The Website's c# code uses the other CS explicitly to connect to the db, but the only reference to the SessionState CS is in Web.config. I have read a lot about Session State and SQLServer mode that past few days, but I haven't found any recommendations for what account to use or why a separate CS is needed for SessionState.
Thanks,
Chris
Update: This is the stack trace from the abend that happens when I substitute my UserID for sa in the Session State CS (I replaced my actual User ID with USERID):
Server Error in '/' Application.
Failed to login to session state SQL server for user 'USERID'.
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.Web.HttpException: Failed to login to session state SQL server for user 'USERID'.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[SqlException (0x80131904): Login failed for user 'USERID'.]
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +4876535
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +194
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1121
System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +35
System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject) +144
System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart) +367
System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +225
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +189
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +185
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +31
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +431
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +66
System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +499
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +65
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +117
System.Data.SqlClient.SqlConnection.Open() +122
System.Web.SessionState.SqlStateConnection..ctor(SqlPartitionInfo sqlPartitionInfo) +93
[HttpException (0x80004005): Failed to login to session state SQL server for user 'USERID'.]
Version Information: Microsoft .NET Framework Version:2.0.50727.5485; ASP.NET Version:2.0.50727.5491
I did finally succeed in creating a user that worked in the Session State CS.
To begin with, rather than running InstallSqlState.sql I ran aspnet_regsql.exe. The SQL file had a warning not to run it standalone and that I should instead use aspnet_regsql.exe, so I did that. I used the following options:
aspnet_regsql.exe -ssadd -sstype p -E -S servername
This created db ASPState and meant that I had to use mode="SQLServer" in in web.config.
I also had to add role 'public' to ASPState as suggested here:
http://forums.asp.net/t/969708.aspx
This post included giving 'public' permissions but did not talk about which ones would be needed, so I had to experiment with that until the CS worked. Permissions were added by right clicking on db ASPState, choosing Properties, selecting Permissions, highlighting database role 'public', then checking off permissions under the 'Grant' heading.
Finally I logged in to SQL Server Management Studio using SQL Server Authentication and created a new user S1. I only gave 'Connect' permission to S1 using the same navigation described above. S1 replaced sa in the session state connection string. Here is the web.config entry for the session state CS. Obviously I changed the pw and servername, but you can see the format I used:
<add name="DVSessionState" connectionString="Data Source=servername;User Id='S1';Password='password'"/>
The following steps describe how to run the InstallSqlState.sql and the UninstallSqlState.sql script files to configure SQL Server mode session state management.
In SQL Query Analyzer, on the File menu, click Open.
In the Open Query File dialog box, browse to the InstallSqlState.sql script file, and then click Open. By default, InstallSqlState.sql is located in one of the following folders:
system drive\WINNT\Microsoft.NET\Framework\version\
system drive\Windows\Microsoft.NET\Framework\version\
After InstallSqlState.sql opens in SQL Query Analyzer, click Execute on the Query menu to run the script.
Before you run the UninstallSqlState.sql script file to uninstall SQL Server mode session state management configuration, you must stop the w3svc process. To do this, follow these steps:
On the Windows Start menu, click Run, type cmd, and then click OK to open a command prompt.
At the command prompt, type net stop w3svc. You receive confirmation that the w3svc process is stopped.
In SQL Query Analyzer, on the File menu, click Open.
In the Open Query File dialog box, browse to the UninstallSqlState.sql script file, and then click Open. By default, UninstallSqlState.sql is located in one of the following folders:
system drive\WINNT\Microsoft.NET\Framework\version\
system drive\Windows\Microsoft.NET\Framework\version\
After UninstallSqlState.sql opens in SQL Query Analyzer, click Execute on the Query menu to run the script.
After you uninstall SQL Server mode session state management configuration, you must restart the w3svc service. To restart the w3svc process, type net start w3svc at a command prompt.
Modify the Web.config File of Your Application
To implement ASP.NET SQL Server mode session state management, you must modify the <sessionState> element of your application's Web.config file as follows:
Set the mode attribute of the <sessionState> element to SQLServer to indicate that session state is stored in SQL Server.
Set the sqlConnectionString attribute to specify the connection string for SQL Server. For example:
sqlConnectionString="data source=MySQLServer;user id=;password="
Note: The user, <user name>, must have permissions to perform this operation on the database.
The modified <sessionState> element should appear as follows:
<sessionState
mode="SQLServer"
sqlConnectionString="data source=127.0.0.1;user id=<username>;password=<strongpassword>"
cookieless="false"
timeout="20"
/>
Note: Ensure that you use the correct case when you specify the <sessionState> element and the associated attribute values. This code is case sensitive.
I write a asp.net website,but when i brower it in iis,and it tips:
Exception: System.ComponentModel.Win32Exception: system can't find specify file。
Source error:
[Win32Exception (0x80004005): The system can't find specify file.]
[SqlException (0x80131904): an instance error associate with network occured when link to SQL Server .Can't find or access to server.Please verify instance name is correct and SQL Server aready configurationa remote link avaliable . (provider: Named Pipes Provider, error: 40 - can't open SQL Server linker)]
EcaClient.ECAService.EcaClientService.GetUserModulePermission(Int32 userId, String moduleType) +120
EcaPortal.CSNavigation.GetCurrentUserModule() in E:\CucEcaPortal\CSNavigation.aspx.cs:113
EcaPortal.CSNavigation.Page_Load(Object sender, EventArgs e) in E:\CucEcaPortal\CSNavigation.aspx.cs:26
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51
System.Web.UI.Control.OnLoad(EventArgs e) +92
System.Web.UI.Control.LoadRecursive() +54
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +772
This is what i aready do:
1.Check the connection string,it is aready correct.
2.reconfiguration the portal in iis.
3.give the portal folder read/write privillege to everyone.
4.restart the iis
5.Search the error from internet if has any usable suggestion.
PS:Yesterday my website is correct and can broswer normal.
the w3wp.exe aways show form and needed visual 2010 to let me debug.
And when i check the process the w3wp.exe using a user name like:Default app pool,is it normal?
Why the iis find path from other location?
My aspx file location is:
E:\appserver\service\CucEcaPortal\CSNavigation.aspx.cs
but it just find from
E:\CucEcaPortal\CSNavigation.aspx.cs
Simply follow these steps,you will get rid to this error:
1.Reset IIS (Start>Run>IIsreset.exe)
2.Clear Cache (Ctrl+Shift+Delete Then Click Clear Now)
3.Clear Temporary File(Start>Run>%Temp% Then Enter,and Delete all Files)
4.Recycle your Website In IIs
5.Stop/Start SQL Servies( Start>Control Panel>Administrative Panel>Services>Sql Server(Sql Express))
and you will Definitely get rid from this error.
i am having no problem at all compiling/debugging my web app, but when i try to run it from my IIS server i get this error:
Server Error in '/' Application.
Login failed for user 'MLABS\STUDENT-006$'.
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: Login failed for user 'MLABS\STUDENT-006$'.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[SqlException (0x80131904): Login failed for user 'MLABS\STUDENT-006$'.]
System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +578
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +88
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +6275911
System.Data.SqlClient.SqlConnection.Open() +258
RadarGraphInsertDLL.LOMDLL.Get_Last_Lom() in c:\users\agordon\documents\visual studio 2008\projects\lomdb\enterdata\radargraphdll\radargraphinsertdll\lomdll.cs:212
EnterData.DataEntry.LOMForm.Page_Load(Object sender, EventArgs e) in C:\Users\agordon\Documents\Visual Studio 2008\Projects\lomdb\EnterData\DataEntry\LOMForm.aspx.cs:20
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +25
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +42
System.Web.UI.Control.OnLoad(EventArgs e) +132
System.Web.UI.Control.LoadRecursive() +66
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2428
Version Information: Microsoft .NET Framework Version:2.0.50727.5448; ASP.NET Version:2.0.50727.5420
STUDENT-006 is my computer name it is not my username! i do not understand why it is trying to login with my computer name.
when the application is run, it immediately should pull data from the database. i have windows authentication enabled and it works without a problem when i run from dubugger, but when i try to compile i get the above error
what am i doing wrong?
MLABS\STUDENT-006$ is the username that the IIS application pool is running as. You either change the application pool user in IIS,
Open IIS Manager. For information about opening IIS Manager, see Open IIS Manager (IIS 7).
In the Connections pane, expand the server node and click Application Pools.
On the Application Pools page, select the application pool for which you want to specify an identity, and then click Advanced
Settings in the Actions pane.
For the Identity property, click the ... button to open the Application Pool Identity dialog box.
If you want to use a built-in account, select the Built-in account option and select an account from the list.
If you want to use a custom identity, select the Custom account option and click Set to open the Set Credentials dialog box. Then type
the custom account name in the User name text box, type a password in
the Password text box, retype the password in the Confirm password
text box, and then click OK.
Click OK to dismiss the Application Pool Identity dialog box.
or you can impersonate in web.config.
<configuration>
<system.web>
<identity impersonate="true"/>
</system.web>
</configuration>
MLABS\STUDENT-006$ is the account that the local "NETWORK SERVICE" account looks like when connecting to other machines and how the server is registered in Active Directory.
This is what the Application Pool in IIS running under, so this connects to SQL Server.
I'd suggest using a domain account especially for this