Webdav.Net Ajax文件浏览器:无法连接到FireFox 20.0.1中的webdav服务器

时间:2013-04-22 20:37:51

标签: ajax webdav ithit-ajax-file-browser

我正在使用下面的代码在.Net Web应用程序项目中显示ajax文件浏览器控件,该项目是我在自动分配的端口上使用开发Web服务器在本地运行的。

webdav服务器在IIS 7(端口80)上本地运行,它是使用webdav.net服务器库的.net应用程序。应用程序中的安全性设置为Windows身份验证。我还允许匿名用户访问OPTIONS请求。

该页面在IE& Chrome,但是FireFox没有连接,它会返回消息:找不到位置“... / WebDav /”。

我启用了Firebug,问题是Webdav服务器向OPTIONS请求返回401 Unauthorized。

还有什么办法可以让它在FireFox中运行吗?

<%@ 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>

感谢

更新1:

我在这里尝试了针对Safari概述的解决方案:http://www.webdavsystem.com/ajaxfilebrowser/programming/authentication_ssl,但它不起作用(Safari和FireFox都没有)。我被提示输入密码,但选项请求仍然是未经授权的。

我还在.Net项目属性 - Web选项卡中启用了NTLM身份验证。 OPTIONS请求仍然无法正常运行。

更新2:

当我在IIS中运行客户端.Net应用程序而不是开发Web服务器(.Net客户端Web应用程序和webdav服务器在端口80上的IIS本地运行)时,我在FireFox中工作。当我在IIS中运行它时,FireFox可以工作,但不能运行Safari。 Safari一直提示我输入密码。我仍然很想知道在本地开发Web服务器上运行客户端应用程序时是否有解决方案。

1 个答案:

答案 0 :(得分:0)

尝试在web.config中使用它:

<authorization>
  <!-- 
  To support Windows Shell (Miniredirector/Web Folders) on XP and Server 2003 as well as Firefox CORS requests, OPTIONS must be 
  processed without authentication. To enable authentication of OPTIONS request, remove "allow OPTIONS" from the list below.
  -->
  <allow users="*" verbs="OPTIONS"/>
  <deny users="?"/>
  <allow users="*"/>
</authorization>