不能在IIS中ASP.NET连接到Outlook,但可以通过Visual Studio中 [英] Cannot connect ASP.NET to Outlook in IIS, but can through Visual Studio

查看:755
本文介绍了不能在IIS中ASP.NET连接到Outlook,但可以通过Visual Studio中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我这样做,开始时真的很容易(不总是发生?),然后拿了一个讨厌的权限转家园项目。

I'm doing a home project that started off really easy (doesn't that always happen?) and then took a nasty permissions turn.

基本上,我有一个家庭内部网和我的个人电脑正在做双责作为主Web服务器。我运行Vista,所以我们谈论的IIS 7。

Basically, I have a home intranet and my PC is doing double-duty as the home web server. I'm running Vista, so we're talking IIS 7.

在Visual Studio中,这个完美的作品。我有我的网页查询展望(2007年),并显示在接下来的约会。我这样做是这样,使用Microsoft.Office.Interop.Outlook

In Visual Studio, this works perfectly. I have my homepage query Outlook (2007) and display the next couple appointments. I do this as so,

using Microsoft.Office.Interop.Outlook;

//Be kind -- this is a work in progress
public static string nextAppointment()
{
    System.Text.StringBuilder returnString = new System.Text.StringBuilder();

        try
        {
            Application outlookApp = new ApplicationClass();
            NameSpace outlookNamespace = outlookApp.GetNamespace("MAPI");
            MAPIFolder theAppts = outlookNamespace.GetDefaultFolder(OlDefaultFolders.olFolderCalendar);

            List<AppointmentItem> todaysAppointments = new List<AppointmentItem>();
            TimeSpan oneday = new TimeSpan(24, 0, 0);
            DateTime today = DateTime.Today;
            DateTime yesterday = today.Subtract(oneday);
            DateTime tomorrow = today.Add(oneday);

            foreach (AppointmentItem someAppt in theAppts.Items)
            {
                if (someAppt.Start > yesterday && someAppt.Start < tomorrow)
                {
                    todaysAppointments.Add(someAppt);
                }
            }

            foreach (AppointmentItem todayAppts in todaysAppointments)
            {
                returnString.Append(todayAppts.Start.ToShortTimeString() + " -- " + todayAppts.Subject + "<br />");
            }
        }
        catch (System.Exception ex)
        {
            //TO-DO: Add some real handling
            returnString.Append("Cannot access calendar");
        }


        return returnString.ToString();
}

这代码片段仅仅是一个进展中的工作,但你的想法。它看起来看到我有一个24小时的时间内什么样的日历事件,然后将它们添加到一个字符串,我终于写出来的网页。当我调试这在Visual Studio中,它贯穿于ASP.NET开发工作室很大。我确信,我采取相同的代码,并在IIS上运行的所有在家里享受,我得到错误(当我不明白我的除外),

This code snippet is just a work in progress, but you get the idea. It looks to see what kind of calendar events I have within a 24 hr period and then adds them to a string that I eventually write-out on the webpage. When I debug this in Visual Studio, it runs great through the ASP.NET Development Studio. Feeling confident, I take the same code and run it on IIS for all at home to enjoy, and I get the error (when I don't catch my exception),

检索COM类工厂CLSID为
{0006F03A-0000-0000-C000-000000000046}

组分失败,原因是以下错误:$ b $ ; b 80070005

Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80070005.

说明:未处理的异常

当前Web请求的执行过程中发生。请查看有关
错误的详细信息,
堆栈跟踪以及它起源于
代码

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

异常详细信息:
System.UnauthorizedAccessException的:
检索COM类工厂CLSID为

组分{0006F03A-0000-0000-C000-000000000046}
失败,原因是以下错误:
80070005

Exception Details: System.UnauthorizedAccessException: Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80070005.

ASP.NET未被授权访问
中的请求的资源。考虑
授予的资源
到ASP.NET请求标识访问权限。
ASP.NET有一个基进程标识
(通常{MACHINE} \ASPNET在IIS 5
或IIS 6上网络服务),即如果应用程序是不使用

冒充。如果应用程序是
。通过冒充的身份
将为匿名用户(通常为
IUSR_MACHINENAME)或经过身份验证
的请求用户。

ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via , the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.

要授予ASP.NET对文件的访问,
在资源管理器中右键单击该文件,
选择属性,选择
安全选项卡。点击添加来添加
适当的用户或组。亮点
ASP.NET帐户,并检查
箱所需的访问。

To grant ASP.NET access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.

我已经试图通过浏览器的网站,但没有运气上改变权限。

I've tried altering permissions through Explorer on the site but no luck.

任何想法?

推荐答案

最后被别的东西完全:

2倍升压 -
(1)输入身份凭据以模拟无论是在web.config中或通过IIS和
(2)给在Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET文件相同的用户

2 fold step -- (1) Enter identity credentials to impersonate either in web.config or through iis and (2) give write access to that same user in Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files

编辑池设置没有任何影响,因为它证明。我可以回去,并把网络服务下池并没有关系。

Editing pool settings has no effect as it turns out. I can go back and put the pool under NetworkService and it doesn't matter.

感谢您的帮助!非常感激!!它肯定把我在正确的轨道

Thanks for your help! Much appreciated!! It definitely put me on the right track

这篇关于不能在IIS中ASP.NET连接到Outlook,但可以通过Visual Studio中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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