设为首页 收藏本站
查看: 523|回复: 0

[经验分享] ASP.NET Word导出服务器权限配置[windows 2003]

[复制链接]

尚未签到

发表于 2015-11-2 13:18:03 | 显示全部楼层 |阅读模式
    System Requirements

  • Microsoft Windows Server 2003 with Service Pack 1
  • MS Word 2003
  • .Net 2.0
  Create a web application. Right click on reference and click on add reference. Select Com tab. Double click on Microsoft Word 11.0 Object Library.
   DSC0000.gif
  Add following code to create a word file at a folder in root directory at server it is Word folder in my case.
Object missing = System.Reflection.Missing.Value;
string file = "myfile";
Object filename = Server.MapPath("Word/") + file;            
object readOnly = false;
object isVisible = true;
Microsoft.Office.Interop.Word.Application oWordApp;
try
{

// initializing Word Application
oWordApp= new Microsoft.Office.Interop.Word.Application();
// initializing Word Document   
Microsoft.Office.Interop.Word.Document oWordDoc = oWordApp.Documents.Add(ref missing, ref missing, ref missing, ref missing);
            
try
{
  oWordDoc.Activate();
    oWordApp.Selection.TypeText("This is the text");
    oWordApp.Selection.TypeParagraph();
    // Saving Word file
    oWordDoc.SaveAs(ref filename, ref missing, ref missing, ref missing,ref missing, ref missing, ref missing, ref missing, ref missing,ref missing, ref missing, ref missing, ref missing, ref missing,ref missing, ref missing);
    }
    catch (Exception ex)
    {
       Response.Write(ex.Message);
    }
    finally
    {
       oWordApp.Application.Quit(ref missing, ref missing, ref missing);
       // Oppening Word file
       Response.Redirect("~/Word/"+file,true);
    }
}
catch (Exception Wex)
{
    Response.Write(Wex.Message);

}
  Now set the Security Permission to the Folder and Com Server

  • Right click on Word Folder select Properties.
  • Go to Security tab and assign the following permissions to the users listed below:
    Security AccountPermissionsASP.NET Machine AccountModify, Read, WriteIIS_WPGModify, Read, WriteInternet Guest Account (IUSR_<MachineName>) *Read, Write                        
    * These all the account created when IIS installed on the machine.Basicaly IUSR_<MachineName> is used for anonymous user to access the your website by default. But we can change this user to some other user.So please make sure that Internet Guest Account is the same security account that is used for Basic Authentication for anonymous access for this application. If not then give same permission to that user as IUSR_<MachineName>)

    Note: If any of the above given security accounts are not already present in the user list then please add the user by following the steps given below:

    • Click on Add

      DSC0001.gif

    • Click on Advanced -> Find Now
    • Select the Particular user
    • Click on ok

      DSC0002.gif


  •   DCOM Config changes

    • Go to Run and type coming and click OK.
    • Go to Component Services/Computers/My Computer/DCOM Config
    • Right click on Microsoft Word Application and go to Properties
    • Go to Security Tab
    • Click on Customize and Edit for each section and give Allow permission for each section to following users
    • 1. ASP.NET Machine Account
    • 2. IIS_WPG,
    • 3. Internet Guest Account(IUSR_<MachineName>) *
      
      * Please make sure that Internet Guest Account is the same security account that is used for Basic Authentication for anonymous access for this application. If not then give same permission to that user as IUSR_<MachineName>

    Note: If any of the above mentioned user is not present in user list then please add that user as mentioned in step10 above.

    DSC0003.gif


  •   Go to the Identity tab. Click on This User and assign a user having administrative privileges on the machine.

    DSC0004.gif

      Note: The Administrative user should have invoked MS Word at least once by logging on to the machine or a complete installation of MS Word 2003 should have been performed. No part of the installation should be remaining.
      

      原文来自:http://hi.baidu.com/upjoyce/blog/item/9c7233385290c82db9998f40.html
      



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-134114-1-1.html 上篇帖子: 解决windows 2003无法下载超过4M的附件的问题 下篇帖子: windows 2003服务器备份和恢复的经验总结
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表