NeatUpload issue uploading pdf and gif files on remote server - c#

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)

Related

Creating a thumbnail from MP4 video crashes on shared hosting but working fine locally

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.

How do i fix this error in WCF services?

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?

ASP CrytographicException: Access is denied

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...

transaction scope gets aborted often

my transaction scope gets aborted often
my problem behind it :
when opening multiple transaction scope with different classes ,we face the error of transaction aborted,each and every class is nested and in the methods the transaction scope is initalized,but the method where the transaction scope declared is not called,but giving timeout and transaction scope gets aborted repeatedly.
My stack trace is as follows :
System.Transactions.TransactionAbortedException was caught
HResult=-2146233087 Message=The transaction has aborted.
Source=System.Transactions
StackTrace:
at System.Transactions.TransactionStatePromotedAborted.CreateAbortingClone(InternalTransaction tx)
at System.Transactions.DependentTransaction..ctor(IsolationLevel isoLevel, InternalTransaction internalTransaction, Boolean blocking)
at System.Transactions.Transaction.DependentClone(DependentCloneOption cloneOption)
at System.Transactions.TransactionScope.SetCurrent(Transaction newCurrent)
at System.Transactions.TransactionScope..ctor(TransactionScopeOption scopeOption)
at TrapError.ErrorDescription..ctor()
at QueryRecordsets.FetchRecordsets..ctor()
InnerException: System.TimeoutException
HResult=-2146233083
Message=Transaction Timeout
InnerException:
while analyzing error description it has the following info :
Event code: 3005
Event message: An unhandled exception has occurred.
Event time: 10/30/2013 9:19:31 AM
Event time (UTC): 10/30/2013 3:49:31 AM
Event ID: 057d425ae7424adbb9a021d856f0d3e0
Event sequence: 14
Event occurrence: 1
Event detail code: 0
Application information:
Application domain: /LM/W3SVC/1/ROOT/eSmartDotNet-2-130275784247371995
Trust level: Full
Application Virtual Path: /eSmartDotNet
Application Path: I:\Rafiq\29-10-2013\Source Code Esmart Application\
Machine name: WINSERVER2012
Process information:
Process ID: 4908
Process name: w3wp.exe
Account name: IIS APPPOOL\DefaultAppPool
Exception information:
Exception type: HttpUnhandledException
Exception message: Exception of type 'System.Web.HttpUnhandledException' was thrown.
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
The transaction has aborted.
at QueryRecordsets.FetchRecordsets..ctor()
at ASP.logincheck_aspx.__Render__control1(HtmlTextWriter __w, Control parameterContainer) in I:\Rafiq\29-10-2013\Source Code Esmart Application\LoginCheck.aspx:line 42
at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
at System.Web.UI.Page.Render(HtmlTextWriter writer)
at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Transaction Timeout
Request information:
Request URL: http://localhost/eSmartDotNet/LoginCheck.aspx
Request path: /eSmartDotNet/LoginCheck.aspx
User host address: ::1
User:
Is authenticated: False
Authentication Type:
Thread account name: IIS APPPOOL\DefaultAppPool
Thread information:
Thread ID: 33
Thread account name: IIS APPPOOL\DefaultAppPool
Is impersonating: False
Stack trace: at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
I'm not sure that TransactionScope will work on Oracle. My gut feel is that it is reliant on MS technologies like MS Distributed Transaction Coordinator (MSDTC). This seems to be confirmed by the MSDN documentation on the System.Transactions namespace where it states (my emphasis indicating MS technologies);
The System.Transactions infrastructure makes transactional programming
simple and efficient throughout the platform by supporting
transactions initiated in SQL Server, ADO.NET, MSMQ, and the Microsoft
Distributed Transaction Coordinator (MSDTC). It provides both an
explicit programming model based on the Transaction class, as well as
an implicit programming model using the TransactionScope class, in
which transactions are automatically managed by the infrastructure.
There are also a bunch of SO posts that seem to indicate they had issues getting it working with Oracle also;
Using TransactionScope with System.Data.OracleClient - TransactionAbortedException
Problems with TransactionScope and Oracle
Transaction Scope in Oracle with ASP.NET
The last link seems to indicate an Oracle specific DTC, but still doesn't offer much hope. You may need to look at other alternatives for handling transactions other than TransactionScope.

Why am I only *randomly* getting "Validation of viewstate MAC failed" in a single server environment?

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.

Categories