从一个asp.net应用程序访问网络共享。工程在Visual Studio中,但不是在IIS,为什么呢? [英] Access a network share from an asp.net app. Works in Visual Studio but not in IIS, why?

查看:239
本文介绍了从一个asp.net应用程序访问网络共享。工程在Visual Studio中,但不是在IIS,为什么呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在企业内部网的网络共享进行写操作给大家(游客)

I have a network share in the intranet that allows write access to everyone (guest)

所以,我写在C#程序(mojoportal模块,反正它是相同的,我认为),在该路径写入一些文件,并在Visual Studio中的伟大工程。

So, i wrote a program (mojoportal module, anyway it's the same, i think) in c# that writes some files in that path, and in visual studio works great.

现在,IIS 7.5中使用相同的程序,不能正常工作,我得到这个异​​常:

Now, using the same program in IIS 7.5, does not work, i get this exception:

System.Net.WebException:一个异常
  一个Web客户端请求期间发生的。
  ---> System.IO.IOException - 登录失败:未知用户名或错误
  密码。

System.Net.WebException: An exception occurred during a WebClient request. ---> System.IO.IOException - Logon failure: unknown user name or bad password.

呃......因为在SMB共享的访问权限授予每个人,我不明白为什么它不能在IIS工作...

Well... since the access on the smb share is granted to everybody, i don't understand why it does not work on IIS...

在code是这样的:

WebClient wc = new WebClient();
wc.DownloadFile(urltodownload, smbshare);

什么可以吗?
谢谢

What it can be? Thanks

推荐答案

您IIS服务没有授予默认访问文件共享。您可以尝试与应用程序池标识设置为本地系统运行您的网站,或手动控制下C $ c都web.config中执行$身份:

Your IIS service not granted to access file share by default. You could try run your site with app pool identity set to Local System, or manually control the identity under which code is executed from web.config:

<system.web>
  <identity impersonate="true" userName="user with correct rights or admin" password="password"/>
  ...

这篇关于从一个asp.net应用程序访问网络共享。工程在Visual Studio中,但不是在IIS,为什么呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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