加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

将ASP.NET部署到Windows Azure云,应用程序在云上运行时会出错

发布时间:2020-12-16 03:23:18 所属栏目:asp.Net 来源:网络整理
导读:我正在尝试在 Windows Azure云中部署ASP.NET应用程序.我正在为应用程序中的一个调用使用Google API.当我这样做时,我收到以下错误: System.UnauthorizedAccessException: Access to the path ‘Google.Apis.Auth’ is denied.` ASP.NET is not authorized to
我正在尝试在 Windows Azure云中部署ASP.NET应用程序.我正在为应用程序中的一个调用使用Google API.当我这样做时,我收到以下错误:

System.UnauthorizedAccessException: Access to the path ‘Google.Apis.Auth’ is denied.`

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 and IIS 7,and the configured application pool identity on IIS 7.5) 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.`

To grant ASP.NET access to a file,right-click the file in File 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.`

我试过研究这个,但所有的建议都谈到了改变IIS服务器的设置,我不相信我有权访问,因为它在云中运行.有人可以帮忙吗?

编辑:这是给出错误的函数的代码:

Async Function SpecialTest() As Task(Of String)

    Dim credential As UserCredential
    Dim clientSecretsPath As String = Server.MapPath("~/App_Data/client_secret.json")
    Dim scopes As IList(Of String) = New List(Of String)()
    scopes.Add(CalendarService.Scope.Calendar)
    Dim stream As FileStream = New FileStream(clientSecretsPath,System.IO.FileMode.Open,System.IO.FileAccess.Read)

    Using stream
        credential = Await GoogleWebAuthorizationBroker.AuthorizeAsync(GoogleClientSecrets.Load(stream).Secrets,scopes,"user3",CancellationToken.None)
    End Using


    Dim baseInitializer = New BaseClientService.Initializer()
    With baseInitializer
        .HttpClientInitializer = credential
        .ApplicationName = "P1"
    End With

    Dim service = New CalendarService(baseInitializer)


    Dim Calendars = (Await service.CalendarList.List().ExecuteAsync()).Items()
    Dim toReturn As String = "{""items"": ["
    For Each firstCalendar As CalendarListEntry In Calendars


        If firstCalendar IsNot Nothing Then
            ' Get all events from the first calendar.
            Dim calEvents = Await service.Events.List(firstCalendar.Id).ExecuteAsync()
            ' DO SOMETHING
            Dim items = calEvents.Items
            'Return JsonConvert.SerializeObject(calEvents)
            For Each ite As Google.Apis.Calendar.v3.Data.Event In items
                If Not (ite.Location Is Nothing) And Not (ite.Start Is Nothing) Then
                    Dim tst = ite.Start.DateTime
                    toReturn = toReturn + " [""" + Date.Parse(ite.Start.DateTime).ToShortDateString + """" + "," + """" + ite.Location + """" + "," + """" + ite.Start.DateTime + """" + "," + """""],"
                End If
            Next

        End If
    Next
    toReturn = toReturn.Substring(0,toReturn.Length - 1)
    Return toReturn + "]}"
End Function`

解决方法

试试这个.

答:如果您有到Azure云的RDP访问权限,则更改IIS设置

> 1.转到IIS
> 2.在站点下选择默认站点
> 3.添加权限
> 4.选择I_User对象并提供读/写访问权限.
> 5.later您可以自动执行此设置using a batch file and startup task.

我认为你正在使用任何本地路径.
您应该将其更改为local storage for temporary requirement and blob storage for long requirement.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读