ASP.NET部署到Windows Azure云,应用云上运行时,给出了错误 [英] Deploying ASP.NET to Windows Azure cloud, application gives error when running on cloud

查看:141
本文介绍了ASP.NET部署到Windows Azure云,应用云上运行时,给出了错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试部署ASP.NET应用程序的Windows Azure云。我使用谷歌API在应用程序调用之一。当我这样做,我得到以下错误:


  

System.UnauthorizedAccessException:对路径Google.Apis.Auth'是denied.`


  
  

ASP.NET未被授权访问所请求的资源。考虑授予资源ASP.NET请求标识访问权限。 ASP.NET有一个基进程标识(通常{MACHINE} \\ ASPNET,在IIS 5或网络服务IIS 6和IIS 7,并在IIS 7.5中配置的应用程序池标识),如果应用程序没有模拟时使用。如果应用程序是通过模仿,则标识将为匿名用户(通常为IUSR_MACHINENAME)或经过身份验证请求user.`


  
  

要ASP.NET访问权限授予某个文件,右键单击文件资源管理器文件,选择属性,然后选择安全选项卡。点击添加添加适当的用户或组。突出显示ASP.NET帐户,并勾选所需access.`


我试图研究这个,但是所有的建议,谈更改IIS服务器设置,我不认为我有机会获得,因为这是在云中运行。谁能帮助?

编辑:这里是code表示的给错误的功能:

 异步功能SpecialTest()作为任务(串)    昏暗的凭据作为UserCredential
    昏暗clientSecretsPath作为字符串=使用Server.Mappath(〜/ App_Data文件/ client_secret.json)
    昏暗的范围作为IList的(字符串)=新名单(串)()
    scopes.Add(CalendarService.Scope.Calendar)
    昏暗的流作为的FileStream =新的FileStream(clientSecretsPath,System.IO.FileMode.Open,System.IO.FileAccess.Read)    使用流
        凭据=等待GoogleWebAuthorizationBroker.AuthorizeAsync(GoogleClientSecrets.Load(流).Secrets,范围,用户3,CancellationToken.None)
    使用完
    昏暗baseInitializer =新BaseClientService.Initializer()
    随着baseInitializer
        .HttpClientInitializer =凭证
        .ApplicationName =P1
    结束与    昏暗的服务=新CalendarService(baseInitializer)
    昏暗的日历=(等待service.CalendarList.List()。ExecuteAsync())。项目()
    昏暗toReturn作为字符串={,项目,:
    对于每个firstCalendar作为CalendarListEntry在日历
        如果firstCalendar状态并没有任何再
            从第一​​个日历中的所有事件。
            昏暗的calEvents =等待service.Events.List(firstCalendar.Id).ExecuteAsync()
            ' 做一点事
            昏暗的项目= calEvents.Items
            '返回JsonConvert.SerializeObject(calEvents)
            对于每一个ITE作为Google.Apis.Calendar.v3.Data.Event在项目
                如果不是(ite.Location为Nothing),而不是(ite.Start是没有什么)然后
                    昏暗TST = ite.Start.DateTime
                    toReturn = toReturn +[+ Date.Parse(ite.Start.DateTime).ToShortDateString ++,+,+ ite.Location ++,+ + ite.Start.DateTime ++,+,+ ite.Start.DateTime ++,+],
                万一
            下一个        万一
    下一个
    toReturn = toReturn.Substring(0,toReturn.Length - 1)
    返回toReturn +]}
结束Function`


解决方案

试试这个。

A 。如果你有RDP查看在Azure云然后更改IIS设置


  • 1.Go到IIS

  • 2.Under网站选择默认网站

  • 3.添加权限

  • 4.选择I_User对象,并给读/写访问。

  • 5.later可以使用批处理这个设置自动文件和启动任务

。我想你使用任何本地路径。
你应该将其更改为对长期需求的临时需求,Blob存储本地存储。

I am trying to deploy an ASP.NET application the Windows Azure cloud. I am using Google API for one of the calls in the application. When I do this, I get the following error:

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.`

I tried researching this, but all the suggestions talk about changing the IIS server settings, which I don't believe I have access to since this is running in the cloud. Can anyone help?

EDIT: here is the code for the function that's giving the error:

 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 + """" + "," + """" + ite.Start.DateTime + """" + "," + """""],"
                End If
            Next

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

解决方案

Try this.

A.If you have RDP Acces to the Azure cloud then change the IIS settings

  • 1.Go to the IIS
  • 2.Under sites select the Default site
  • 3.Add Permission
  • 4.choose I_User object and give read/write access.
  • 5.later you can automate this setting using a batch file and startup task.

B.I think you are using any local path. You should change this to local storage for temporary requirement and blob storage for long requirement.

这篇关于ASP.NET部署到Windows Azure云,应用云上运行时,给出了错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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