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...
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 am currently attempting to use WCF services to input data into a database,
I have been following the steps of this tutorial: http://www.c-sharpcorner.com/UploadFile/rohatash/inserting-data-into-database-using-wcf-service/
and I have reached the end of it successfully:
enter image description here
however, when I press the button, data does not get put into the database; instead this message pops up:
Server Error in '/' Application.
The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework SDK documentation and inspect the server trace logs.
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.ServiceModel.FaultException: The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework SDK documentation and inspect the server trace logs.
Source Error:
Line 146:
Line 147: public string InsertUserDetails(WebAppTest2.ServiceReference1.UserDetails userInfo) {
Line 148: return base.Channel.InsertUserDetails(userInfo);
Line 149: }
Line 150:
Source File: c:\users\mauro-buhagiarjl(848\documents\visual studio 2015\Projects\WebAppTest2\WebAppTest2\Service References\ServiceReference1\Reference.cs Line: 148
Stack Trace:
[FaultException: The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework SDK documentation and inspect the server trace logs.]
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +153
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +336
WebAppTest2.ServiceReference1.IService1.InsertUserDetails(UserDetails userInfo) +0
WebAppTest2.ServiceReference1.Service1Client.InsertUserDetails(UserDetails userInfo) in c:\users\mauro-buhagiarjl(848\documents\visual studio 2015\Projects\WebAppTest2\WebAppTest2\Service References\ServiceReference1\Reference.cs:148
WebAppTest2.WebFormTest.Button1_Click(Object sender, EventArgs e) in c:\users\mauro-buhagiarjl(848\documents\visual studio 2015\Projects\WebAppTest2\WebAppTest2\WebFormTest.aspx.cs:27
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9712582
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.6.1637.0
Any Ideas to where this message originates from?
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.
Yes, there are a million questions and threads on this particular error, with many well-documented solutions, which I will definitely try. But first I want to understand the problem for my particular situation/environment.
In my situation, this error seems to be entirely random. I will go weeks without seeing it, then one day I'll log into my site and get the error. Refresh the page, login again, and no problem. During these periods in between incidents, nothing particularly special has happened to the web server.
And that's the other thing, the error says "If this application is hosted by a Web Farm or cluster...", but it's not. It's just one single Windows Server 2008.
So, I understand the general solution is to add a set of static machine keys to the web.config file --- but why does this happen seemingly at random, and why does it happen to my site which is on a single Windows Server 2008 machine?
I'm using ASP.NET 4 and my site is a Web Application running on IIS.
Error Message:
Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.
Stack Trace:
[ViewStateException: Invalid viewstate.
Client IP: ##::##:##:##:##
Port: ##
Referer: http://myserver/login.aspx
Path: /login.aspx
User-Agent: Opera/9.80 (Windows NT 6.1; WOW64; U; en) Presto/2.10.289 Version/12.01
ViewState: /wEPDw...6OCX]
[HttpException (0x80004005): Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.]
System.Web.UI.ViewStateException.ThrowError(Exception inner, String persistedState, String errorPageMessage, Boolean macValidationError) +235
System.Web.UI.ViewStateException.ThrowMacValidationError(Exception inner, String persistedState) +14
System.Web.UI.ObjectStateFormatter.Deserialize(String inputString) +274
System.Web.UI.ObjectStateFormatter.System.Web.UI.IStateFormatter.Deserialize(String serializedState) +4
System.Web.UI.Util.DeserializeWithAssert(IStateFormatter formatter, String serializedState) +37
System.Web.UI.HiddenFieldPageStatePersister.Load() +241
System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +106
System.Web.UI.Page.LoadAllState() +43
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +8431
System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +253
System.Web.UI.Page.ProcessRequest() +78
System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +21
System.Web.UI.Page.ProcessRequest(HttpContext context) +49
ASP.login_aspx.ProcessRequest(HttpContext context) +4
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +100
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75
From your log, I suggest you to check one thing - Did you connect any parameter from your user with the Viewstate that can be changed if the user is logged in/logged out? - or change for any other reason, e.g. because session is expired or changed.
This parameter can be different between the saved and the current Viewstate and this can break the page.
For example this code can do that:
ViewStateUserKey = CurrentUserCookie;
Or this one as it is:
ViewStateUserKey = User.Identity.Name
Also read this answer: https://stackoverflow.com/a/2551810/159270
This is similar:
ViewStateUserKey + shared hosting + ViewStateMac validation failure
And Some reference:
http://www.hanselman.com/blog/ViewStateUserKeyMakesViewStateMoreTamperresistant.aspx
http://msdn.microsoft.com/en-us/library/ms972969.aspx
The random errors are the nightmare of any developer.
We've recently run into this issue whereby pdf and gif files will not upload successfully on our remote system test server. Other file formats such as .docx, .xls, .jpg work and all file types work in the development environment. Both servers are Windows Server 2008 R2 Standard, IIS7.5 and run an asp.net 4.0 web application.
On searching google I've seen some references to making sure to use .close() properly, which I think I do as this works for other file types and on dev. Also in terms of permissions to the app_data\NeatUpload_Temp folder, I've ensured that the running account has write access.
Here's some pseudo C# code: -
if(inputFile.HasFile)
{
//Get the uploaded content
byte[] fileBytes = ReadContentsFromUploadedFile(inputFile);
//Get the uploaded file name
string fileName = GetFileNameFromUploadedFile(inputFile);
//Get the MIME type
string mimeType = inputFile.ContentType;
//Create custom object and store doc in SharePoint via web service
inputFile.FileContent.Close();
}
And a snippet from the Web.config: -
<neatUpload xmlns="http://www.brettle.com/neatupload/config/2008" useHttpModule="true" maxNormalRequestLength="102400" maxRequestLength="102400" defaultStorageProvider="FilesystemUploadStorageProvider" defaultStateStoreProvider="InProcUploadStateStoreProvider">
<providers>
<add name="FilesystemUploadStorageProvider" type="Brettle.Web.NeatUpload.FilesystemUploadStorageProvider, Brettle.Web.NeatUpload"/>
<add name="InProcUploadStateStoreProvider" type="Brettle.Web.NeatUpload.InProcUploadStateStoreProvider, Brettle.Web.NeatUpload"/>
</providers>
</neatUpload>
Any help or direction much appreciated!
Stack trace below: -
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.IO.IOException: The process cannot access the file 'C:\inetpub\wwwroot\UWP_SIT\app_data\NeatUpload_Temp\5b25efcf6e9246c1b989640f623486c0.config' because it is being used by another process.
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:
[IOException: The process cannot access the file 'C:\inetpub\wwwroot\UWP_SIT\app_data\NeatUpload_Temp\5b25efcf6e9246c1b989640f623486c0.config' because it is being used by another process.]
System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +12896359
System.IO.FileInfo.Delete() +183
Brettle.Web.NeatUpload.FilesystemUploadedFile.Dispose() +909
Brettle.Web.NeatUpload.FileControl.OnUnload(EventArgs e) +235
System.Web.UI.Control.UnloadRecursive(Boolean dispose) +160
System.Web.UI.Control.UnloadRecursive(Boolean dispose) +323
System.Web.UI.Control.UnloadRecursive(Boolean dispose) +323
System.Web.UI.Control.UnloadRecursive(Boolean dispose) +323
System.Web.UI.Control.UnloadRecursive(Boolean dispose) +323
System.Web.UI.Control.UnloadRecursive(Boolean dispose) +323
System.Web.UI.Control.UnloadRecursive(Boolean dispose) +323
System.Web.UI.Control.UnloadRecursive(Boolean dispose) +323
System.Web.UI.Control.UnloadRecursive(Boolean dispose) +323
System.Web.UI.Control.UnloadRecursive(Boolean dispose) +323
System.Web.UI.Control.UnloadRecursive(Boolean dispose) +323
System.Web.UI.Control.UnloadRecursive(Boolean dispose) +323
System.Web.UI.Control.UnloadRecursive(Boolean dispose) +323
System.Web.UI.Page.UnloadRecursive(Boolean dispose) +24
System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +11351550
System.Web.UI.Page.ProcessRequest() +269
System.Web.UI.Page.ProcessRequest(HttpContext context) +167
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +625
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +270
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1
It looks like the web application doesn't have permission to save the files to the destination.
You should check the permissions in two places:
neatupload's temp upload directory (where the files go before their
transfers are complete) the destination directory (the location where
you move them to once they are complete)