I am using the code below to display the ajax file browser control in a .Net Web app project that I run locally using the development web server on an auto assigned port.
The webdav server runs locally on IIS 7 (port 80), it is a .net app using the webdav.net server library. The security in the app is set Windows Authentication. I also allow anonymous users to the OPTIONS request.
The page works fine in IE & Chrome, however FireFox doesn't connect, it returns the message: Location ".../WebDav/" not found.
I enabled Firebug and the problem is that the Webdav server returns a 401 Unauthorized to the OPTIONS request.
Is there anything that can be done to make it work in FireFox as well?
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>
<!DOCTYPE HTML>
<html>
<head>
<title>IT Hit AJAX File Browser</title>
<!-- Always set width and height for html and body if you would like to set width and height for Ajax File Browser control to 100% -->
<style type="text/css">
@import "AjaxFileBrowser/themes/ih_vista/include.css";
html, body {margin: 0px; padding: 0px; width: 100%; height: 100%;}
</style>
<script src="AjaxFileBrowser/ITHitAJAXFileBrowser.js" type="text/javascript"></script>
<script type="text/javascript">
function InitAjaxFileBrowser() {
// Here we assume that your server is located on site root (http://server/) on the domain from which this page is loaded.
// If your WebDAV server is located on a different domain or on a different port the server must attach the Access-Control-Allow headers to server responses.
var port = window.location.port == '' ? '' : ':' + window.location.port;
var webDavServerPath = window.location.protocol + '//' + window.location.hostname + port;
webDavServerPath = "http://localhost/WebDav";
// Create the AJAX File Browser Settings object.
var settings = {
Id: 'AjaxFileBrowserContainer', // (required) ID of the HTML control in which Ajax File Browser will be created
Url: webDavServerPath, // (required) the root folder to be displyed in Ajax File browser
Style: 'height: 100%; width: 100%', // (required) always provide size of the control
FileIconsPath: '/TestWebDavAjaxFileBrowser/AjaxFileBrowser/icons/', // (required) path to the folder where file icons are located
MsOfficeTemplatesPath: webDavServerPath + '/', // path to MS Office templates, always specify full path
SelectedFolder: webDavServerPath, // folder to be selected, same as SetSelectedFolder call
PluginsPath: '/TestWebDavAjaxFileBrowser/AjaxFileBrowser/plugins/' // path to Java applet that opens documents directly from server
};
//Create control.
var ajaxFileBrowser = new ITHit.WebDAV.Client.AjaxFileBrowser.Controller(settings);
}
</script>
</head>
<body class="ih_vista" onload="InitAjaxFileBrowser();">
<div id="AjaxFileBrowserContainer" style="width: 100%; height: 100%"></div>
</body>
</html>
thanks
Update 1:
I tried the solution outlined for Safari here: http://www.webdavsystem.com/ajaxfilebrowser/programming/authentication_ssl, however it doesn't work (neither Safari nor FireFox). I am prompted for password but the options request is still Unauthorized.
I also enabled NTLM Authentication in the .Net project properties - Web tab. Still doesn't work the OPTIONS request comes back as unauthorized.
Update 2:
I got it working in FireFox when I run the client .Net app in IIS rather than the development web server (the .Net client web app and the webdav server run locally in IIS on port 80). When I run it in IIS, FireFox works but not Safari. Safari keeps prompting me for password. I am still curious to see if there is a solution when running the client app in the local development web server.
Try using this in web.config: