I have encoutered a question when I run ASP.NET on Mono+Apache2.
I put a FileUpload Control in a Page,when click button to upload the file it will throw an Exception:
Could not find a part of the path "/var/www/www.mysite.com/upload/headImage/uid_1.jpg".
Description: HTTP 500. Error processing request.
Stack Trace:
System.IO.DirectoryNotFoundException: Could not find a part of the path "/var/www/www.mysite.com/upload/headImage/uid_1.jpg".
at System.IO.File.Delete (System.String path) [0x00000] in :0
at System.Web.HttpPostedFile.SaveAs (System.String filename) [0x00000] in :0
at System.Web.UI.WebControls.FileUpload.SaveAs (System.String filename) [0x00000] in >:0
at WebApplication.users.ImageUpload.btnUpload_Click (System.Object sender, >System.EventArgs e) [0x00000] in :0
at System.Web.UI.WebControls.Button.OnClick (System.EventArgs e) [0x00000] in :0
at System.Web.UI.WebControls.Button.RaisePostBackEvent (System.String eventArgument) >[0x00000] in :0
at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent >(System.String eventArgument) [0x00000] in :0
at System.Web.UI.Page.RaisePostBackEvent (IPostBackEventHandler sourceControl, >System.String eventArgument) [0x00000] in :0
at System.Web.UI.Page.RaisePostBackEvents () [0x00000] in :0
at System.Web.UI.Page.ProcessRaiseEvents () [0x00000] in :0
at System.Web.UI.Page.InternalProcessRequest () [0x00000] in :0
at System.Web.UI.Page.ProcessRequest (System.Web.HttpContext context) [0x00000] in :0
I'm sure the path "/var/www/www.mysite.com/upload/headImage/" exist and have been chmod 766 and there isn't exists "uid_1.jpg" in that folder.
Source code:
string fileName = "uid_1.jpg";
string imageUrl = "/upload/headImage/" + fileName;
fileName = Path.Combine(Server.MapPath("~/upload/headImage/"), fileName);
if (File.Exists(fileName))
{
File.Delete(fileName);
}
upload.SaveAs(fileName);
Could anyone can tell how to do?
Thanks.
I got it!
When I use chmod 777 /var/www/www.mysite.com/upload/headImage/,I found I can upload files to server now.
Related
enter image description hereThere's signature popup first time with none enter(signature stoke) close the popup by clicking on cancel button and once more reopening the popup and providing a input(stroke) once after stoke is completed variable is set to true
On onpropertychange throwing below excetion
System.ObjectDisposedException: 'Cannot access a disposed object.
Object name: 'AndroidX.AppCompat.Widget.AppCompatButton'.'
enter image description hereenter image description here
Stack Trace
at Java.Interop.JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self) [0x00029] in :0
at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualBooleanMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00000] in :0
at Android.Views.View.get_Enabled () [0x00000] in /Users/builder/azdo/work/1/s/xamarin-android/src/Mono.Android/obj/Release/monoandroid10/android-29/mcw/Android.Views.View.cs:6262
at XF.Material.Droid.Renderers.MaterialDrawableHelper.CreateStateListAnimator () [0x00000] in /Users/martijn/Documents/OpenSource/XF-Material-Library/XF.Material/Platforms/Android/Renderers/MaterialDrawableHelper.cs:291
at XF.Material.Droid.Renderers.MaterialDrawableHelper.UpdateElevation () [0x00008] in /Users/martijn/Documents/OpenSource/XF-Material-Library/XF.Material/Platforms/Android/Renderers/MaterialDrawableHelper.cs:286
at XF.Material.Droid.Renderers.MaterialDrawableHelper.BindableButton_PropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) [0x00029] in /Users/martijn/Documents/OpenSource/XF-Material-Library/XF.Material/Platforms/Android/Renderers/MaterialDrawableHelper.cs:110
at (wrapper delegate-invoke) .invoke_void_object_PropertyChangedEventArgs(object,System.ComponentModel.PropertyChangedEventArgs)
at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:266
at Xamarin.Forms.Element.OnPropertyChanged (System.String propertyName) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Element.cs:362
at XF.Material.Forms.UI.MaterialButton.OnPropertyChanged (System.String propertyName) [0x0001a] in /Users/martijn/Documents/OpenSource/XF-Material-Library/XF.Material/UI/MaterialButton.cs:108
at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) [0x00114] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:510
at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x00173] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:446
at Xamarin.Forms.BindingExpression.ApplyCore (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property, System.Boolean fromTarget) [0x00226] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:160
at Xamarin.Forms.BindingExpression.Apply (System.Boolean fromTarget) [0x0003e] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:56
at Xamarin.Forms.BindingExpression+BindingExpressionPart.b__49_0 () [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:762
at Xamarin.Forms.BindingExpression+BindingExpressionPart.PropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs args) [0x000cb] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:773
at Xamarin.Forms.BindingExpression+WeakPropertyChangedProxy.OnPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) [0x00012] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:666
at (wrapper delegate-invoke) .invoke_void_object_PropertyChangedEventArgs(object,System.ComponentModel.PropertyChangedEventArgs)
at XamarinUniversity.Infrastructure.SimpleViewModel.RaisePropertyChanged (System.String propertyName) [0x00012] in :0
at ICR_MobileApp.ViewModels.SignatureSectionViewModel.OnStrokeCompleted () [0x0001c] in C:\Users\supriya.mecharla\source\repos\ICR_MobileApp\ICR_MobileApp\ICR_MobileApp\ViewModels\SectionViewModels\SignatureSectionViewModel.cs:262
at ICR_MobileApp.ViewModels.SignatureSectionViewModel.<.ctor>b__50_6 () [0x00000] in C:\Users\supriya.mecharla\source\repos\ICR_MobileApp\ICR_MobileApp\ICR_MobileApp\ViewModels\SectionViewModels\SignatureSectionViewModel.cs:168
at Xamarin.Forms.Command+<>c__DisplayClass4_0.<.ctor>b__0 (System.Object o) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Command.cs:74
at Xamarin.Forms.Command.Execute (System.Object parameter) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Command.cs:112
at SignaturePad.Forms.SignaturePadCanvasView.OnStrokeCompleted () [0x00039] in :0
at SignaturePad.Forms.SignaturePadCanvasRenderer.OnStrokeCompleted (System.Object sender, System.EventArgs e) [0x0000a] in :0
at Xamarin.Controls.SignaturePadCanvasView.OnStrokeCompleted (System.Object sender, System.EventArgs e) [0x0000a] in <0c0873655a504a1796935fa2cfa62e06>:0
at Xamarin.Controls.InkPresenter.OnStrokeCompleted () [0x0000a] in <0c0873655a504a1796935fa2cfa62e06>:0
at Xamarin.Controls.InkPresenter.TouchesEnded (Android.Views.MotionEvent e) [0x0003c] in <0c0873655a504a1796935fa2cfa62e06>:0
at Xamarin.Controls.InkPresenter.OnTouchEvent (Android.Views.MotionEvent e) [0x0002e] in <0c0873655a504a1796935fa2cfa62e06>:0
at Android.Views.View.n_OnTouchEvent_Landroid_view_MotionEvent (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_e) [0x00010] in /Users/builder/azdo/_work/1/s/xamarin-android/src/Mono.Android/obj/Release/monoandroid10/android-29/mcw/Android.Views.View.cs:18286
at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.35(intptr,intptr,intptr)
I'm running apache server on Ubuntu, and I'm trying to get a asp site to run. When I go into a page I get a 404 with the following stack trace:
at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) [0x0021a] in <dca3b561b8ad4f9fb10141d81b39ff45>:0
at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share) [0x00000] in <dca3b561b8ad4f9fb10141d81b39ff45>:0
at (wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare)
at System.IO.File.OpenRead (System.String path) [0x00000] in <dca3b561b8ad4f9fb10141d81b39ff45>:0
at Microsoft.CodeDom.Providers.DotNetCompilerPlatform.Compiler.get_CompilerName () [0x00019] in <fa43aae1d96f44db88d3b8a258fd9425>:0
at Microsoft.CodeDom.Providers.DotNetCompilerPlatform.Compiler.FromFileBatch (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) [0x00168] in <fa43aae1d96f44db88d3b8a258fd9425>:0
at Microsoft.CodeDom.Providers.DotNetCompilerPlatform.Compiler.CompileAssemblyFromFileBatch (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) [0x00048] in <fa43aae1d96f44db88d3b8a258fd9425>:0
at System.CodeDom.Compiler.CodeDomProvider.CompileAssemblyFromFile (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) [0x00014] in <59be416de143456b88b9988284f43350>:0
at System.Web.Compilation.AssemblyBuilder.BuildAssembly (System.Web.VirtualPath virtualPath, System.CodeDom.Compiler.CompilerParameters options) [0x002f5] in <d3ba84a338d241e2ab5397407351c9cd>:0
at System.Web.Compilation.AssemblyBuilder.BuildAssembly (System.Web.VirtualPath virtualPath) [0x00008] in <d3ba84a338d241e2ab5397407351c9cd>:0
at System.Web.Compilation.BuildManager.GenerateAssembly (System.Web.Compilation.AssemblyBuilder abuilder, System.Web.Compilation.BuildProviderGroup group, System.Web.VirtualPath vp, System.Boolean debug) [0x00264] in <d3ba84a338d241e2ab5397407351c9cd>:0
at System.Web.Compilation.BuildManager.BuildInner (System.Web.VirtualPath vp, System.Boolean debug) [0x0011c] in <d3ba84a338d241e2ab5397407351c9cd>:0
at System.Web.Compilation.BuildManager.Build (System.Web.VirtualPath vp) [0x00063] in <d3ba84a338d241e2ab5397407351c9cd>:0
at System.Web.Compilation.BuildManager.GetCompiledType (System.Web.VirtualPath virtualPath) [0x00040] in <d3ba84a338d241e2ab5397407351c9cd>:0
at System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath (System.Web.VirtualPath virtualPath, System.Type requiredBaseType) [0x00012] in <d3ba84a338d241e2ab5397407351c9cd>:0
at System.Web.UI.PageParser.GetCompiledPageInstance (System.String virtualPath, System.String inputFile, System.Web.HttpContext context) [0x00024] in <d3ba84a338d241e2ab5397407351c9cd>:0
at System.Web.UI.PageHandlerFactory.GetHandler (System.Web.HttpContext context, System.String requestType, System.String url, System.String path) [0x00000] in <d3ba84a338d241e2ab5397407351c9cd>:0
at System.Web.HttpApplication.GetHandler (System.Web.HttpContext context, System.String url, System.Boolean ignoreContextHandler) [0x00065] in <d3ba84a338d241e2ab5397407351c9cd>:0
at System.Web.HttpApplication.GetHandler (System.Web.HttpContext context, System.String url) [0x00000] in <d3ba84a338d241e2ab5397407351c9cd>:0
at System.Web.HttpApplication+<Pipeline>c__Iterator1.MoveNext () [0x0086b] in <d3ba84a338d241e2ab5397407351c9cd>:0
This stack trace doen't really help me - there is no data as to what line, what parameters where send to the function, and in total - I don't know what resource is missing.
How can I get a better stack trace?
Try to look at the Mono Project.
They have a module for the Apache server called «mod_mono».
Hope this helps.
Try the Mod.Mono
This handles ASP.NET 4.0 (with the exception of Entity Framework).
See the compatibility for more information on what Mono is compatible with.
ASP.NET MVC3 application is hosted in Apache in Mono as virtual host with address http://www.mysite.com
Requests for files robots.txt , favicon.ico and apple-touch-icon.png cause 404 error below since
there are no MVC3 controllers for those names.
How to server those files ? It it possible to force Apache to serve them as regular files or can we force MVC3 application to return those files ?
Which is proper way to implement this ?
System.Web.HttpException: The controller for path '/robots.txt' was not found or does not implement IController.
at System.Web.Mvc.DefaultControllerFactory.GetControllerInstance (System.Web.Routing.RequestContext requestContext, System.Type controllerType) [0x00000] in <filename unknown>:0
at System.Web.Mvc.DefaultControllerFactory.CreateController (System.Web.Routing.RequestContext requestContext, System.String controllerName) [0x00000] in <filename unknown>:0
at System.Web.Mvc.MvcHandler.ProcessRequestInit (System.Web.HttpContextBase httpContext, IController& controller, IControllerFactory& factory) [0x00000] in <filename unknown>:0
at System.Web.Mvc.MvcHandler+<>c__DisplayClass6.<BeginProcessRequest>b__2 () [0x00000] in <filename unknown>:0
at System.Web.Mvc.SecurityUtil+<>c__DisplayClassb`1[System.IAsyncResult].<ProcessInApplicationTrust>b__a () [0x00000] in <filename unknown>:0
at System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0 (System.Action f) [0x00000] in <filename unknown>:0
at System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust (System.Action action) [0x00000] in <filename unknown>:0
at System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust[IAsyncResult] (System.Func`1 func) [0x00000] in <filename unknown>:0
at System.Web.Mvc.MvcHandler.BeginProcessRequest (System.Web.HttpContextBase httpContext, System.AsyncCallback callback, System.Object state) [0x00000] in <filename unknown>:0
at System.Web.Mvc.MvcHandler.BeginProcessRequest (System.Web.HttpContext httpContext, System.AsyncCallback callback, System.Object state) [0x00000] in <filename unknown>:0
at System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest (System.Web.HttpContext context, System.AsyncCallback cb, System.Object extraData) [0x00000] in <filename unknown>:0
at System.Web.HttpApplication+<Pipeline>c__Iterator3.MoveNext () [0x00000] in <filename unknown>:0
at System.Web.HttpApplication.Tick () [0x00000] in <filename unknown>:0
Fixing robots.txt:
Right click the project name and select "Add->New Item"
Choose "Text File" and call it "robots.txt"
You can leave this file blank
Fixing favicon.ico:
Go to the RegisterRoutes method of the Global.asax.cs file and add this near the top: You can look at this page for more info: Favicon Icon-MVC3 ASP.NET
routes.IgnoreRoute("{*favicon}", new { favicon = #"(.*/)?favicon.ico(/.*)?" });
Fixing apple-touch-icon.png:
Look at these websites
Why am I getting error for apple-touch-icon-precomposed.png
http://mathiasbynens.be/notes/touch-icons
I installed mono from source on a Centos 6.4 to test a msc asp web site.
It seems to work fine all but
some pages return this error
System.InvalidOperationException
Failed to map path '/'
Description: HTTP 500.Error processing request.
Details: Non-web exception. Exception origin (name of application or object):
System.Web.
at System.Web.HttpRequest.MapPath (System.String virtualPath, System.String baseVirtualDir, Boolean allowCrossAppMapping) [0x00000] in <filename unknown>:0
at System.Web.HttpRequest.MapPath (System.String virtualPath) [0x00000] in <filename unknown>:0
at System.Web.Hosting.HostingEnvironment.MapPath (System.String virtualPath) [0x00000] in <filename unknown>:0
at System.Web.Hosting.DefaultVirtualPathProvider.DirectoryExists (System.String virtualDir) [0x00000] in <filename unknown>:0
at System.Web.Configuration.WebConfigurationManager.FindWebConfig (System.String path, System.Boolean& inAnotherApp) [0x00000] in <filename unknown>:0
at System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration (System.String path, System.String site, System.String locationSubPath, System.String server, System.String userName, System.String password, Boolean fweb) [0x00000] in <filename unknown>:0
at System.Web.Configuration.WebConfigurationManager.GetSection (System.String sectionName, System.String path, System.Web.HttpContext context) [0x00000] in <filename unknown>:0
at System.Web.Configuration.WebConfigurationManager.GetSection (System.String sectionName, System.String path) [0x00000] in <filename unknown>:0
at System.Web.Security.SqliteMembershipProvider.Initialize (System.String name, System.Collections.Specialized.NameValueCollection config) [0x00000] in <filename unknown>:0
at System.Web.Configuration.ProvidersHelper.InstantiateProvider (System.Configuration.ProviderSettings providerSettings, System.Type providerType) [0x00000] in <filename unknown>:0
at System.Web.Configuration.ProvidersHelper.InstantiateProviders (System.Configuration.ProviderSettingsCollection configProviders, System.Configuration.Provider.ProviderCollection providers, System.Type providerType) [0x00000] in <filename unknown>:0
at System.Web.Security.Membership..cctor () [0x00000] in <filename unknown>:0
I did the same thing on a debian and It works fine.
Do you have any suggestions?
Find all your Server.MapPaths and change from
Server.MapPaths(#"\")
to
Server.MapPaths(Path.DirectorySeparatorChar)
Have you checked the paths in your view files? Just as a reminder:
'/' like in <script src="/myScript.js"></script> maps to the DocumentRoot folder defined on your /sites-available/.conf, it may be something like /var/www
'~/' like in <script src="#Url.Content("~/scripts/script1.js")"></script> maps to the path where your mvc application is, it may be somethin like /var/www/site1
'../' would try to access one folder above the DocumentRoot folder. This may actually be forbbiden by your apache site configuration (recommended).
Also note that if your run your mvc app from monodevelop/xspServer the document root and the mvc application path are actually the same but if you install your mvc app on apache they may not be the same path.
This error occurs because there is a bug in mono System.Web
It contain this check (https://github.com/mono/mono/blob/mono-3.2.1-branch/mcs/class/System.Web/System.Web/HttpRequest.cs#L1565)
if (!isAppVirtualPath && !virtualPath.StartsWith (appVirtualPath, RuntimeHelpers.StringComparison))
throw new InvalidOperationException (String.Format ("Failed to map path '{0}'", virtualPath));
To fix this, you can comment those lines in Mono surce code and re-compile Mono.
This bug is in latest Mono also.
Links:
https://bugzilla.xamarin.com/show_bug.cgi?id=24457
I had the same error, with exactly the same stacktrace.
It only occured on the first request when apache was just started. The error did not occur after the first request.
I solved this by removing WebMatrix.WebData.dll
This will probably have some consequences when you use SimpleMembershipProvider and it might affect OpenAuth functionality on MVC4.
I have an Apache server with mod_mono hooked up to a legacy ASP.NET application. I can't seem to get this application to work if I move it from a top level folder.
For example, the following mono .webapp successfully works at http://localhost/Service.asmx (as my web app is in folder2):
<apps>
<web-application>
<name>Test</name>
<vpath>/</vpath>
<path>/srv/aspnettest/folder1/folder2</path>
<vhost>localhost</vhost>
</web-application>
</apps>
However, due to a legacy URL, I need my web application to exist two subfolders deeper like so:
<apps>
<web-application>
<name>Test</name>
<vpath>/</vpath>
<path>/srv/aspnettest/</path>
<vhost>localhost</vhost>
</web-application>
</apps>
If I try to go to http://localhost/folder1/folder2/Service.asmx it fails with
HTTP 500. Error processing request.
Stack Trace:
System.Web.HttpException: Type MyType.Service not found.
at System.Web.UI.SimpleWebHandlerParser.GetTypeFromBin (System.String tname) [0x00000] in <filename unknown>:0
at System.Web.Compilation.SimpleBuildProvider.LoadTypeFromBin (System.Web.Compilation.BaseCompiler compiler, System.Web.UI.SimpleWebHandlerParser parser) [0x00000] in <filename unknown>:0
at System.Web.Compilation.GenericBuildProvider`1[TParser].GetGeneratedType (System.CodeDom.Compiler.CompilerResults results) [0x00000] in <filename unknown>:0
at System.Web.Compilation.BuildManagerCacheItem..ctor (System.Reflection.Assembly assembly, System.Web.Compilation.BuildProvider bp, System.CodeDom.Compiler.CompilerResults results) [0x00000] in <filename unknown>:0
at System.Web.Compilation.BuildManager.StoreInCache (System.Web.Compilation.BuildProvider bp, System.Reflection.Assembly compiledAssembly, System.CodeDom.Compiler.CompilerResults results) [0x00000] in <filename unknown>:0
at System.Web.Compilation.BuildManager.GenerateAssembly (System.Web.Compilation.AssemblyBuilder abuilder, System.Web.Compilation.BuildProviderGroup group, System.Web.VirtualPath vp, Boolean debug) [0x00000] in <filename unknown>:0
at System.Web.Compilation.BuildManager.BuildInner (System.Web.VirtualPath vp, Boolean debug) [0x00000] in <filename unknown>:0
at System.Web.Compilation.BuildManager.Build (System.Web.VirtualPath vp) [0x00000] in <filename unknown>:0
at System.Web.Compilation.BuildManager.GetCompiledType (System.Web.VirtualPath virtualPath) [0x00000] in <filename unknown>:0
at System.Web.Compilation.BuildManager.GetCompiledType (System.String virtualPath) [0x00000] in <filename unknown>:0
at System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler (System.Web.HttpContext context, System.String verb, System.String url, System.String filePath) [0x00000] in <filename unknown>:0
at System.Web.HttpApplication.GetHandler (System.Web.HttpContext context, System.String url, Boolean ignoreContextHandler) [0x00000] in <filename unknown>:0
at System.Web.HttpApplication.GetHandler (System.Web.HttpContext context, System.String url) [0x00000] in <filename unknown>:0
at System.Web.HttpApplication+<Pipeline>c__Iterator2.MoveNext () [0x00000] in <filename unknown>:0
How can I successfully get a web app in subfolders? Thanks.
Turns out this was an Apache configuration issue that was unrelated but caused this as a side effect. I had my VirtualHost setup incorrectly.