authority problem with C# programming with word

ju_feng 2003-03-20 02:24:02
i have set the write access right as requested as follows but i still get unfavorable reply as follows,what should i do? your early reply will be appreciated.
(follows:)
拒绝访问。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: System.UnauthorizedAccessException: 拒绝访问。

未授权此 ASP.NET 进程访问所请求的资源。出于安全原因,默认的 ASP.NET 进程标识为“{machinename}\ASPNET”,它只具有有限的特权。请考虑授予该 ASP.NET 进程标识访问此资源的权限。

若要授予 ASP.NET 对文件的写访问权,请在资源管理器中右击该文件,选择“属性”,然后选择“安全”选项卡。单击“添加”以添加“{machinename}\ASPNET”用户。突出显示此 ASP.NET 帐户,在“允许”列中选中“写”框。

源错误:


行 51: private void Button1_Click(object sender, System.EventArgs e)
行 52: {
行 53: Word.Application wordApp= new Word.Application();
行 54: Word.Document wordDoc= new Word.Document();
行 55: // object strDocFile=server.MapPath("D:\\ConsultRpt\\医药行业.doc");


源文件: C:\Inetpub\wwwroot\WebApplication2\WebForm1.aspx.cs 行: 53

堆栈跟踪:


[UnauthorizedAccessException: 拒绝访问。]
WebApplication2.WebForm1.Button1_Click(Object sender, EventArgs e) in C:\Inetpub\wwwroot\WebApplication2\WebForm1.aspx.cs:53
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1263




--------------------------------------------------------------------------------
版本信息: Microsoft .NET 框架版本:1.0.3705.288; ASP.NET 版本:1.0.3705.288
...全文
60 10 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
sunlite 2003-03-24
  • 打赏
  • 举报
回复
hi,bigyu7:)
Thank you!!!!!!!!
Just as what you said,i didnot set the open authority before.
And now,according to you----my teacher's advice,every thing seems OK.
Good luck!
bigyu7 2003-03-24
  • 打赏
  • 举报
回复
sunlite:
在安全性中要设置两个权限:启动权限和访问权限!
我也遇到过跟你一样的问题,错误提示也一样,就是这样解决的。
bigyu7 2003-03-22
  • 打赏
  • 举报
回复
1、运行dcomcnfg
2、设置word的属性:
安全性 -- 自定义启动和访问权限,增加aspnet用户
身份标示 --- 选择交互式用户
3、ok!
sunlite 2003-03-22
  • 打赏
  • 举报
回复
hi,bigyu7:)
I 运行dcomcnfg is you told me but errors as usual.would you be so kind to tell me as soon as possible?
good luck.
the errors as follows:
“/WebApplication7”应用程序中的服务器错误。
--------------------------------------------------------------------------------

拒绝访问。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: System.UnauthorizedAccessException: 拒绝访问。

未授权此 ASP.NET 进程访问所请求的资源。出于安全原因,默认的 ASP.NET 进程标识为“{machinename}\ASPNET”,它只具有有限的特权。请考虑授予该 ASP.NET 进程标识访问此资源的权限。

若要授予 ASP.NET 对文件的写访问权,请在资源管理器中右击该文件,选择“属性”,然后选择“安全”选项卡。单击“添加”以添加“{machinename}\ASPNET”用户。突出显示此 ASP.NET 帐户,在“允许”列中选中“写”框。

源错误:


行 20: {
行 21: // 在此处放置用户代码以初始化页面
行 22: Word.ApplicationClass app = new Word.ApplicationClass();
行 23: app.Visible=true;
行 24: Object o=Missing.Value;


源文件: c:\inetpub\wwwroot\webapplication7\webform1.aspx.cs 行: 22

堆栈跟踪:


[UnauthorizedAccessException: 拒绝访问。]
WebApplication7.WebForm1.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\webapplication7\webform1.aspx.cs:22
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()




--------------------------------------------------------------------------------
版本信息: Microsoft .NET 框架版本:1.0.3705.288; ASP.NET 版本:1.0.3705.288
sunlite 2003-03-22
  • 打赏
  • 举报
回复
hi,jkeen:)
First I'd like to express my sincire appreciation of your timely help.but i try your two suggestions but i failed.i donot know why.
the prompt is as follows:

“/WebApplication7”应用程序中的服务器错误。
--------------------------------------------------------------------------------

配置错误
说明: 在处理向该请求提供服务所需的配置文件时出错。请检查下面的特定错误详细信息并适当地修改配置文件。

分析器错误信息: 未能从配置文件中指定的凭据创建 Windows 用户标记。源自操作系统的错误“客户没有所需的特权。 ”

源错误:


行 36: “Passport”和“None”
行 37: -->
行 38: <identity impersonate="true" userName="MyComputer\ASPNET" />
行 39:
行 40: <authentication mode="Windows" />


源文件: c:\inetpub\wwwroot\WebApplication7\web.config 行: 38

your early reply will be appreciated.thanks a lot!

hi,bigyu7:)
good nite.thank you very much.but i am sorry to say that i donot know what dcomcnfg is and how to 运行dcomcnfg.would you be so kind to tell me as soon as possible?
good luck.


--------------------------------------------------------------------------------
版本信息: Microsoft .NET 框架版本:1.0.3705.288; ASP.NET 版本:1.0.3705.288
jkeen 2003-03-22
  • 打赏
  • 举报
回复
解决方案:
asp.net可以做身份扮演。
在web.config的<configuration><system.web>节中加入:
<identity impersonate="true" userName="YouDomain\userid" password="xxx" />

如果不设置域用户,也可以设置本机用户,如:userName="MyComputer\userA",这样,你将userA添加到‘D:\\ConsultRpt\\’的访问用户里去就OK了。

不过有一个问题,那就是password是Clear Text的,但是微软的一位高级顾问在解决我们这个问题的时候是这样讲的,在下一版的framework中将解决Clear Text的问题。

祝好运!
sunlite 2003-03-21
  • 打赏
  • 举报
回复
no,it's just win2k server.pls give me a answer.thank u.by the way,Your name reminds me a hero character in mid-century----tang herd.
Knight94 2003-03-21
  • 打赏
  • 举报
回复
Your system is WinXP, isn't it?
ju_feng 2003-03-20
  • 打赏
  • 举报
回复
i tried adding ASPNET user to Administrators组中,but error as usual.more important,it's not a practical solution because that way,everyone could edit the word doc on the serverside.
any more suggestion available?
Knight94 2003-03-20
  • 打赏
  • 举报
回复
试试给Asp.net用户增加到Administrators组中试试

111,097

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧