映射文件夹无法使用IIS进行发布 [英] Mapped folder not working on publish with IIS

查看:73
本文介绍了映射文件夹无法使用IIS进行发布的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个Web应用程序。我必须在按钮单击中显示一个附件。附件文件驻留在同一网络中的另一个服务器上。当我使编码在我的开发机器中运行良好时,但是当我部署它时它不起作用。



i我在192.168.a.xyz服务器中部署应用程序映射的文件夹位于192.168.a.ijk。



i使用了以下代码,该代码在同一网络中的开发机器中运行良好。



我正在创建一个Web应用程序。我必须在按钮单击中显示一个附件。附件文件驻留在同一网络中的另一个服务器上。当我使编码在我的开发机器中运行良好时,但是当我部署它时它不起作用。



i我在192.168.a.xyz服务器中部署应用程序映射的文件夹位于192.168.a.ijk。



i使用了以下代码,该代码在同一网络中的开发机器中运行良好。





如果有人可以提供帮助,感激不尽!



我尝试过的:



I am creating an web application. I have to show one attachment in a button click.The attachment file resides on another server which is in the same network. when i make the coding its works well in my development machine, but when i deploy it does not work.

i am deploying the application in 192.168.a.xyz server and the mapped folder is in 192.168.a.ijk.

i have used the below code which works well in the development machine which is also in the same network.

I am creating an web application. I have to show one attachment in a button click.The attachment file resides on another server which is in the same network. when i make the coding its works well in my development machine, but when i deploy it does not work.

i am deploying the application in 192.168.a.xyz server and the mapped folder is in 192.168.a.ijk.

i have used the below code which works well in the development machine which is also in the same network.


Appreciate if anybody can help!

What I have tried:

public ActionResult GetCorporateInvoiceCopy(string attachId)
        {
            if (attachId.Length > 0)
            {
                try
                {
                    string FileExtension = ".pdf";
                    string csvPath = "";
                    string inv = attachId;
                    csvPath = @"\\192.168.a.ijk\\Attached_Files\" + Path.GetFileName(inv.ToString() + FileExtension );
                    return File(csvPath, FileExtension);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            else
            {
                return null;
            }
        }

推荐答案

它适用于您的机器,因为当您编写代码并在您的机器上进行测试时机器在你的帐户下运行。由于您可以访问其他网络资源,因此代码可以工作。



现在,当在Web服务器上运行代码时,它在默认的ASP.NET帐户下运行。默认情况下,出于非常好的安全原因,无法访问您尝试访问的网络资源。



您必须创建一个用户剥离用户帐户以运行您的网站。此帐户还必须为代码尝试访问的网络资源提供适当的Share和NTFS权限。然后,您可以更改运行您站点的应用程序池以使用此帐户。



希望您在Active Directory中运行这些计算机以使其更易于管理?如果没有,祝你好运。
It works on your machine because when you write the code and tested it on your machine it was running under YOUR ACCOUNT. Since you have access to the other network resource, the code works.

Now, when running the code on the web server, it's running under a default ASP.NET account. By default, and for very good security reasons, has no access to the network resource you're trying to get to.

You have to create a user stripped down user account to run your site under. This account would also have to be given appropriate Share and NTFS permissions to the network resource the code is trying to get to. You then change the Application Pool running your site to use this account.

Hopefully, you've got these machines running in Active Directory to make this a bit easier to manage? If not, good luck.


这篇关于映射文件夹无法使用IIS进行发布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆