Pretty new to C # and MVC. I have an MVC application setup in which the webapp is running Chrome as a browser. I have a button inside webapp (html) from which the user can select the folders that he wants, and then I want them to be in fact.
To do this, I make an ajax request to my MVC controller, which will open folderBrowserDialog (System.Windows.Forms) and then return the path back as an ajax response. Everything works fine when I run the application with visual studio. But after creating the application package and installing exe, the BrowserDialog folder does not appear at all. There are no errors causing the ajax response correctly with null
here is the code (part of it)
selectFolderGlobal - global variable
public JObject OpenFolderExplorer() { try { Thread fb= new Thread(new ThreadStart(openFileBrowser), 1); fb.SetApartmentState(ApartmentState.STA); fb.Start(); fb.Join(); JObject selectedFolder = new JObject(); selectedFolder.Add("selectedFolder", selectedFolderGlobal); return selectedFolder; } catch (Exception ex) { Logger.Log(" Exception: " + ex.Message); JObject errorcode = JObject.Parse(mConstants.EXCEPTION); return errorcode; } } private void openFileBrowser() { try { var fbd= new FolderBrowserDialog(); fbd.ShowNewFolderButton = false; DialogResult result = fbd.ShowDialog(new Form() { TopMost = true, WindowState = FormWindowState.Minimized }); if (result == DialogResult.OK) { selectedFolderGlobal= fbd.SelectedPath; } } catch (Exception ex) { Logger.Entry(" Exception: " + ex.Message); } }
Ajax response is returned this way
{ "selectedFolder":null }
Does anyone know why this can happen only after creating the package (after extracting .exe from it)? System.Windows.Forms.dll is added to the dependencies (if this should not have been done, or even building the packages would have failed)
c # ajax
P-rad
source share