2013-04-22 167 views
0

我正在使用下面的代码在我使用开发Web服务器在本地运行的.Net Web应用程序项目中显示ajax文件浏览器控件在一个自动分配的端口上。Webdav.Net Ajax文件浏览器:无法连接到FireFox中的webdav服务器20.0.1

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

该页面在IE浏览器中工作正常& Chrome浏览器,但是FireFox未连接,它返回消息:找不到位置“.../WebDav /”。

我启用了Firebug,问题在于Webdav服务器返回401未授权给OPTIONS请求。

有没有什么可以做到使它在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浏览器,也不火狐)。我被提示输入密码,但选项请求仍然未经授权。

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

更新2:

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

回答

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>