asp.net在其他服务器中创建文件夹和文件

[英]asp.net create folder and file in other server


In my asp.net application I have an option to take photographs, these photographs should not store the hosting server, the photographs should be stored on another server. (\192.168.1.103\ca\photos\ I use this code

在我的asp.net应用程序中,我可以选择拍照,这些照片不应该存储托管服务器,照片应该存储在另一台服务器上。 (\ 192.168.1.103 \ ca \ photos \我使用此代码

public void EstructuraReclamo(string Producto, string Poliza, string Sucursal,string Reclamo, string Item) {
string Mensaje = string.Empty;
string DirServidor = DireccionIP(ref Mensaje, "SCANDATOS", Sucursal, "RECLAMOS");           
try
{
    string DirReclamo =DirServidor + Producto + @"\" + Poliza + @"\Item" + Item + @"\" + Reclamo;
    if (!System.IO.Directory.Exists(DirReclamo)){
        System.IO.Directory.CreateDirectory(DirReclamo);
    }
    System.Data.DataTable dtSubdirectorios = ListaSubDirectorio(ref Mensaje, "SCANRECLAMO");
    foreach (System.Data.DataRow dr in dtSubdirectorios.Rows) { 
        string SubDir = DirReclamo + @"\" + dr["apa_glosa"].ToString();
        if (!System.IO.Directory.Exists(SubDir))
            System.IO.Directory.CreateDirectory(SubDir);
    }

}
catch (Exception ex){
    Mensaje = ex.Message.ToString();
}

But the folders are not created? When I execute the program from VS2010 the folders are created, but when publish the site the folders are no created How I can solve this problem?

但是文件夹没有创建?当我从VS2010执行程序时,会创建文件夹,但是在发布站点时,文件夹没有创建我怎么能解决这个问题?

The version IIS is 6.0

IIS版本是6.0

2 个解决方案

#1


2  

Though I don't know whether or not you're getting an exception at the moment, this is almost assuredly a permissions issue. IIS is going to send the credentials the Application Pool is running under when trying to create the folders. This is generally defaulted to NETWORK SERVICE.

虽然我不知道你目前是否收到例外,但这几乎肯定是一个权限问题。在尝试创建文件夹时,IIS将发送应用程序池正在运行的凭据。这通常默认为NETWORK SERVICE。

Have a look at the user the Application Pool is running under, then check out the permissions of the root folder, and ensure that user has Write access.

查看运行应用程序池的用户,然后检查根文件夹的权限,并确保用户具有写访问权限。

Once the Application Pool user has permissions -you're good.

一旦应用程序池用户拥有权限 - 你就是好人。

#2


0  

This will be a permissions issue, when you run the program using visual studio the application runs with your own credentials, however when the site is run in IIS it will run with whichever account is assigned to the application pool and by default this will be a local account on the machine which won't have any permissions on a remote server.

这将是一个权限问题,当您使用visual studio运行程序时,应用程序使用您自己的凭据运行,但是当该站点在IIS中运行时,它将使用分配给应用程序池的任何帐户运行,并且默认情况下这将是机器上的本地帐户,对远程服务器没有任何权限。

If you use impersonation you can setup an account which has the relevant permissions on the remote server and your application will have access to those remote folders/files.

如果您使用模拟,则可以设置一个在远程服务器上具有相关权限的帐户,您的应用程序将可以访问这些远程文件夹/文件。


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2013/06/13/bfe7d7e2cef205dc00d7a5456b882ea6.html



 
  © 2014-2022 ITdaan.com 联系我们: